Compare commits
2 commits
7d78a74a25
...
66744ddd10
Author | SHA1 | Date | |
---|---|---|---|
66744ddd10 | |||
d91e832eab |
20 changed files with 304 additions and 326 deletions
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
|
@ -1,3 +1,3 @@
|
||||||
{
|
{
|
||||||
"github-enterprise.uri": "https://git.creations.works"
|
"github-enterprise.uri": "https://git.creations.works"
|
||||||
}
|
}
|
||||||
|
|
35
biome.json
Normal file
35
biome.json
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
||||||
|
"vcs": {
|
||||||
|
"enabled": true,
|
||||||
|
"clientKind": "git",
|
||||||
|
"useIgnoreFile": false
|
||||||
|
},
|
||||||
|
"files": {
|
||||||
|
"ignoreUnknown": false,
|
||||||
|
"ignore": []
|
||||||
|
},
|
||||||
|
"formatter": {
|
||||||
|
"enabled": true,
|
||||||
|
"indentStyle": "tab",
|
||||||
|
"lineEnding": "lf"
|
||||||
|
},
|
||||||
|
"organizeImports": {
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
"linter": {
|
||||||
|
"enabled": true,
|
||||||
|
"rules": {
|
||||||
|
"recommended": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"javascript": {
|
||||||
|
"formatter": {
|
||||||
|
"quoteStyle": "double",
|
||||||
|
"indentStyle": "tab",
|
||||||
|
"lineEnding": "lf",
|
||||||
|
"jsxQuoteStyle": "double",
|
||||||
|
"semicolons": "always"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,8 @@
|
||||||
export const environment: Environment = {
|
export const environment: Environment = {
|
||||||
port: parseInt(process.env.PORT || "8080", 10),
|
port: Number.parseInt(process.env.PORT || "8080", 10),
|
||||||
host: process.env.HOST || "0.0.0.0",
|
host: process.env.HOST || "0.0.0.0",
|
||||||
development:
|
development:
|
||||||
process.env.NODE_ENV === "development" ||
|
process.env.NODE_ENV === "development" || process.argv.includes("--dev"),
|
||||||
process.argv.includes("--dev"),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const lanyardConfig: LanyardConfig = {
|
export const lanyardConfig: LanyardConfig = {
|
||||||
|
|
132
eslint.config.js
132
eslint.config.js
|
@ -1,132 +0,0 @@
|
||||||
import pluginJs from "@eslint/js";
|
|
||||||
import tseslintPlugin from "@typescript-eslint/eslint-plugin";
|
|
||||||
import tsParser from "@typescript-eslint/parser";
|
|
||||||
import prettier from "eslint-plugin-prettier";
|
|
||||||
import promisePlugin from "eslint-plugin-promise";
|
|
||||||
import simpleImportSort from "eslint-plugin-simple-import-sort";
|
|
||||||
import unicorn from "eslint-plugin-unicorn";
|
|
||||||
import unusedImports from "eslint-plugin-unused-imports";
|
|
||||||
import globals from "globals";
|
|
||||||
|
|
||||||
/** @type {import('eslint').Linter.FlatConfig[]} */
|
|
||||||
export default [
|
|
||||||
{
|
|
||||||
files: ["**/*.{js,mjs,cjs}"],
|
|
||||||
languageOptions: {
|
|
||||||
globals: globals.node,
|
|
||||||
},
|
|
||||||
...pluginJs.configs.recommended,
|
|
||||||
plugins: {
|
|
||||||
"simple-import-sort": simpleImportSort,
|
|
||||||
"unused-imports": unusedImports,
|
|
||||||
promise: promisePlugin,
|
|
||||||
prettier: prettier,
|
|
||||||
unicorn: unicorn,
|
|
||||||
},
|
|
||||||
rules: {
|
|
||||||
"eol-last": ["error", "always"],
|
|
||||||
"no-multiple-empty-lines": ["error", { max: 1, maxEOF: 1 }],
|
|
||||||
"no-mixed-spaces-and-tabs": ["error", "smart-tabs"],
|
|
||||||
"simple-import-sort/imports": "error",
|
|
||||||
"simple-import-sort/exports": "error",
|
|
||||||
"unused-imports/no-unused-imports": "error",
|
|
||||||
"unused-imports/no-unused-vars": [
|
|
||||||
"warn",
|
|
||||||
{
|
|
||||||
vars: "all",
|
|
||||||
varsIgnorePattern: "^_",
|
|
||||||
args: "after-used",
|
|
||||||
argsIgnorePattern: "^_",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"promise/always-return": "error",
|
|
||||||
"promise/no-return-wrap": "error",
|
|
||||||
"promise/param-names": "error",
|
|
||||||
"promise/catch-or-return": "error",
|
|
||||||
"promise/no-nesting": "warn",
|
|
||||||
"promise/no-promise-in-callback": "warn",
|
|
||||||
"promise/no-callback-in-promise": "warn",
|
|
||||||
"prettier/prettier": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
useTabs: true,
|
|
||||||
tabWidth: 4,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
indent: ["error", "tab", { SwitchCase: 1 }],
|
|
||||||
"unicorn/filename-case": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
case: "camelCase",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
files: ["**/*.{ts,tsx}"],
|
|
||||||
languageOptions: {
|
|
||||||
parser: tsParser,
|
|
||||||
globals: globals.node,
|
|
||||||
},
|
|
||||||
plugins: {
|
|
||||||
"@typescript-eslint": tseslintPlugin,
|
|
||||||
"simple-import-sort": simpleImportSort,
|
|
||||||
"unused-imports": unusedImports,
|
|
||||||
promise: promisePlugin,
|
|
||||||
prettier: prettier,
|
|
||||||
unicorn: unicorn,
|
|
||||||
},
|
|
||||||
rules: {
|
|
||||||
...tseslintPlugin.configs.recommended.rules,
|
|
||||||
quotes: ["error", "double"],
|
|
||||||
"eol-last": ["error", "always"],
|
|
||||||
"no-multiple-empty-lines": ["error", { max: 1, maxEOF: 1 }],
|
|
||||||
"no-mixed-spaces-and-tabs": ["error", "smart-tabs"],
|
|
||||||
"simple-import-sort/imports": "error",
|
|
||||||
"simple-import-sort/exports": "error",
|
|
||||||
"unused-imports/no-unused-imports": "error",
|
|
||||||
"unused-imports/no-unused-vars": [
|
|
||||||
"warn",
|
|
||||||
{
|
|
||||||
vars: "all",
|
|
||||||
varsIgnorePattern: "^_",
|
|
||||||
args: "after-used",
|
|
||||||
argsIgnorePattern: "^_",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"promise/always-return": "error",
|
|
||||||
"promise/no-return-wrap": "error",
|
|
||||||
"promise/param-names": "error",
|
|
||||||
"promise/catch-or-return": "error",
|
|
||||||
"promise/no-nesting": "warn",
|
|
||||||
"promise/no-promise-in-callback": "warn",
|
|
||||||
"promise/no-callback-in-promise": "warn",
|
|
||||||
"prettier/prettier": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
useTabs: true,
|
|
||||||
tabWidth: 4,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
indent: ["error", "tab", { SwitchCase: 1 }],
|
|
||||||
"unicorn/filename-case": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
case: "camelCase",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"@typescript-eslint/explicit-function-return-type": ["error"],
|
|
||||||
"@typescript-eslint/explicit-module-boundary-types": ["error"],
|
|
||||||
"@typescript-eslint/typedef": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
arrowParameter: true,
|
|
||||||
variableDeclaration: true,
|
|
||||||
propertyDeclaration: true,
|
|
||||||
memberVariableDeclaration: true,
|
|
||||||
parameter: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
17
package.json
17
package.json
|
@ -5,24 +5,15 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "bun run src/index.ts",
|
"start": "bun run src/index.ts",
|
||||||
"dev": "bun run --hot src/index.ts --dev",
|
"dev": "bun run --hot src/index.ts --dev",
|
||||||
"lint": "eslint",
|
"lint": "bunx biome check",
|
||||||
"lint:fix": "bun lint --fix",
|
"lint:fix": "bunx biome check --fix",
|
||||||
"cleanup": "rm -rf logs node_modules bun.lockdb"
|
"cleanup": "rm -rf logs node_modules bun.lockdb"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.24.0",
|
"@biomejs/biome": "^1.9.4",
|
||||||
"@types/bun": "^1.2.8",
|
"@types/bun": "^1.2.8",
|
||||||
"@types/ejs": "^3.1.5",
|
"@types/ejs": "^3.1.5",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.29.0",
|
"globals": "^16.0.0"
|
||||||
"@typescript-eslint/parser": "^8.29.0",
|
|
||||||
"eslint": "^9.24.0",
|
|
||||||
"eslint-plugin-prettier": "^5.2.6",
|
|
||||||
"eslint-plugin-promise": "^7.2.1",
|
|
||||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
||||||
"eslint-plugin-unicorn": "^58.0.0",
|
|
||||||
"eslint-plugin-unused-imports": "^4.1.4",
|
|
||||||
"globals": "^16.0.0",
|
|
||||||
"prettier": "^3.5.3"
|
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"typescript": "^5.8.3"
|
"typescript": "^5.8.3"
|
||||||
|
|
|
@ -12,7 +12,7 @@ body {
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
background: #1a1a1d;
|
background: #1a1a1d;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
box-shadow: 0 0 20px rgba(0,0,0,0.3);
|
box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
|
||||||
}
|
}
|
||||||
.error-title {
|
.error-title {
|
||||||
font-size: 2rem;
|
font-size: 2rem;
|
||||||
|
|
|
@ -1,7 +1,38 @@
|
||||||
|
:root {
|
||||||
|
--background: #0e0e10;
|
||||||
|
--card-bg: #1e1f22;
|
||||||
|
--card-hover-bg: #2a2a2d;
|
||||||
|
--border-color: #2e2e30;
|
||||||
|
|
||||||
|
--text-color: #ffffff;
|
||||||
|
--text-subtle: #bbb;
|
||||||
|
--text-secondary: #b5bac1;
|
||||||
|
--text-muted: #888;
|
||||||
|
--link-color: #00b0f4;
|
||||||
|
|
||||||
|
--status-online: #23a55a;
|
||||||
|
--status-idle: #f0b232;
|
||||||
|
--status-dnd: #e03e3e;
|
||||||
|
--status-offline: #747f8d;
|
||||||
|
--status-streaming: #b700ff;
|
||||||
|
|
||||||
|
--progress-bg: #f23f43;
|
||||||
|
--progress-fill: #5865f2;
|
||||||
|
|
||||||
|
--button-bg: #5865f2;
|
||||||
|
--button-hover-bg: #4752c4;
|
||||||
|
--button-disabled-bg: #2d2e31;
|
||||||
|
|
||||||
|
--blockquote-color: #aaa;
|
||||||
|
--code-bg: #2e2e30;
|
||||||
|
|
||||||
|
--readme-bg: #1a1a1d;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: system-ui, sans-serif;
|
font-family: system-ui, sans-serif;
|
||||||
background-color: #0e0e10;
|
background-color: var(--background);
|
||||||
color: #ffffff;
|
color: var(--text-color);
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -52,26 +83,30 @@ body {
|
||||||
width: 24px;
|
width: 24px;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
border: 4px solid #0e0e10;
|
border: 4px solid var(--background);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-indicator.online {
|
.status-indicator.online {
|
||||||
background-color: #23a55a;
|
background-color: var(--status-online);
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-indicator.idle {
|
.status-indicator.idle {
|
||||||
background-color: #f0b232;
|
background-color: var(--status-idle);
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-indicator.dnd {
|
.status-indicator.dnd {
|
||||||
background-color: #f23f43;
|
background-color: var(--status-dnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-indicator.offline {
|
.status-indicator.offline {
|
||||||
background-color: #747f8d;
|
background-color: var(--status-offline);
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-indicator.streaming {
|
||||||
|
background-color: var(--status-streaming);
|
||||||
}
|
}
|
||||||
|
|
||||||
.platform-icon.mobile-only {
|
.platform-icon.mobile-only {
|
||||||
|
@ -91,12 +126,12 @@ body {
|
||||||
h1 {
|
h1 {
|
||||||
font-size: 2.5rem;
|
font-size: 2.5rem;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
color: #00b0f4;
|
color: var(--link-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.custom-status {
|
.custom-status {
|
||||||
font-size: 1.2rem;
|
font-size: 1.2rem;
|
||||||
color: #bbb;
|
color: var(--text-subtle);
|
||||||
margin-top: 0.25rem;
|
margin-top: 0.25rem;
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
overflow-wrap: anywhere;
|
overflow-wrap: anywhere;
|
||||||
|
@ -107,7 +142,6 @@ h1 {
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.custom-status .custom-emoji {
|
.custom-status .custom-emoji {
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
|
@ -142,14 +176,14 @@ ul {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
background-color: #1e1f22;
|
background-color: var(--card-bg);
|
||||||
padding: 0.75rem 1rem;
|
padding: 0.75rem 1rem;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
box-shadow: 0 1px 0 0 #2e2e30;
|
border: 1px solid var(--border-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.activity:hover {
|
.activity:hover {
|
||||||
background: #2a2a2d;
|
background: var(--card-hover-bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.activity-wrapper {
|
.activity-wrapper {
|
||||||
|
@ -164,7 +198,28 @@ ul {
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.activity-art {
|
.activity-image-wrapper {
|
||||||
|
position: relative;
|
||||||
|
width: 80px;
|
||||||
|
height: 80px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.activity-image-small {
|
||||||
|
width: 25px;
|
||||||
|
height: 25px;
|
||||||
|
border-radius: 50%;
|
||||||
|
object-fit: cover;
|
||||||
|
flex-shrink: 0;
|
||||||
|
border-color: var(--card-bg);
|
||||||
|
border-width: 2px;
|
||||||
|
border-style: solid;
|
||||||
|
|
||||||
|
position: absolute;
|
||||||
|
bottom: -6px;
|
||||||
|
right: -10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.activity-image {
|
||||||
width: 80px;
|
width: 80px;
|
||||||
height: 80px;
|
height: 80px;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
|
@ -202,17 +257,17 @@ ul {
|
||||||
.activity-name {
|
.activity-name {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
color: #fff;
|
color: var(--text-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.activity-detail {
|
.activity-detail {
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
color: #b5bac1;
|
color: var(--text-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.activity-timestamp {
|
.activity-timestamp {
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
color: #b5bac1;
|
color: var(--text-secondary);
|
||||||
text-align: right;
|
text-align: right;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
@ -220,14 +275,14 @@ ul {
|
||||||
|
|
||||||
.progress-bar {
|
.progress-bar {
|
||||||
height: 4px;
|
height: 4px;
|
||||||
background-color: #2e2e30;
|
background-color: var(--border-color);
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
margin-top: 0.5rem;
|
margin-top: 1rem;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.progress-fill {
|
.progress-fill {
|
||||||
background-color: #5865f2;
|
background-color: var(--progress-fill);
|
||||||
transition: width 0.4s ease;
|
transition: width 0.4s ease;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
@ -235,14 +290,13 @@ ul {
|
||||||
.progress-bar,
|
.progress-bar,
|
||||||
.progress-time-labels {
|
.progress-time-labels {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-top: 0.5rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.progress-time-labels {
|
.progress-time-labels {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
color: #888;
|
color: var(--text-muted);
|
||||||
margin-top: 0.25rem;
|
margin-top: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,7 +310,7 @@ ul {
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #aaa;
|
color: var(--blockquote-color);
|
||||||
margin-bottom: 0.50rem;
|
margin-bottom: 0.50rem;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
@ -267,7 +321,7 @@ ul {
|
||||||
|
|
||||||
.progress-time-labels.paused .progress-current::after {
|
.progress-time-labels.paused .progress-current::after {
|
||||||
content: " ⏸";
|
content: " ⏸";
|
||||||
color: #f0b232;
|
color: var(--status-idle);
|
||||||
}
|
}
|
||||||
|
|
||||||
.activity-buttons {
|
.activity-buttons {
|
||||||
|
@ -278,7 +332,7 @@ ul {
|
||||||
}
|
}
|
||||||
|
|
||||||
.activity-button {
|
.activity-button {
|
||||||
background-color: #5865f2;
|
background-color: var(--progress-fill);
|
||||||
color: white;
|
color: white;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
@ -291,12 +345,12 @@ ul {
|
||||||
}
|
}
|
||||||
|
|
||||||
.activity-button:hover {
|
.activity-button:hover {
|
||||||
background-color: #4752c4;
|
background-color: var(--button-hover-bg);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.activity-button:disabled {
|
.activity-button:disabled {
|
||||||
background-color: #2d2e31;
|
background-color: var(--button-disabled-bg);
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
}
|
}
|
||||||
|
@ -325,6 +379,13 @@ ul {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.activity-image-wrapper {
|
||||||
|
max-width: 100%;
|
||||||
|
max-height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.avatar-wrapper {
|
.avatar-wrapper {
|
||||||
width: 96px;
|
width: 96px;
|
||||||
height: 96px;
|
height: 96px;
|
||||||
|
@ -379,21 +440,31 @@ ul {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
border-radius:0;
|
border-radius: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.activity-art {
|
.activity-image {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 300px;
|
max-width: 100%;
|
||||||
height: auto;
|
height: auto;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.activity-image-small {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
.activity-content {
|
.activity-content {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.activity-wrapper-inner {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
.activity-header {
|
.activity-header {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
@ -430,12 +501,12 @@ ul {
|
||||||
|
|
||||||
/* readme :p */
|
/* readme :p */
|
||||||
.readme {
|
.readme {
|
||||||
max-width: 600px;
|
max-width: 700px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background: #1a1a1d;
|
background: var(--readme-bg);
|
||||||
padding: 1.5rem;
|
padding: 1.5rem;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
box-shadow: 0 0 0 1px #2e2e30;
|
border: 1px solid var(--border-color);
|
||||||
|
|
||||||
margin-top: 2rem;
|
margin-top: 2rem;
|
||||||
|
|
||||||
|
@ -446,13 +517,13 @@ ul {
|
||||||
|
|
||||||
.readme h2 {
|
.readme h2 {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
color: #00b0f4;
|
color: var(--link-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.markdown-body {
|
.markdown-body {
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
color: #ddd;
|
color: var(--text-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.markdown-body h1,
|
.markdown-body h1,
|
||||||
|
@ -461,7 +532,7 @@ ul {
|
||||||
.markdown-body h4,
|
.markdown-body h4,
|
||||||
.markdown-body h5,
|
.markdown-body h5,
|
||||||
.markdown-body h6 {
|
.markdown-body h6 {
|
||||||
color: #ffffff;
|
color: var(--text-color);
|
||||||
margin-top: 1.25rem;
|
margin-top: 1.25rem;
|
||||||
margin-bottom: 0.5rem;
|
margin-bottom: 0.5rem;
|
||||||
}
|
}
|
||||||
|
@ -471,7 +542,7 @@ ul {
|
||||||
}
|
}
|
||||||
|
|
||||||
.markdown-body a {
|
.markdown-body a {
|
||||||
color: #00b0f4;
|
color: var(--link-color);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,7 +551,7 @@ ul {
|
||||||
}
|
}
|
||||||
|
|
||||||
.markdown-body code {
|
.markdown-body code {
|
||||||
background: #2e2e30;
|
background: var(--border-color);
|
||||||
padding: 0.2em 0.4em;
|
padding: 0.2em 0.4em;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
|
@ -488,7 +559,7 @@ ul {
|
||||||
}
|
}
|
||||||
|
|
||||||
.markdown-body pre {
|
.markdown-body pre {
|
||||||
background: #2e2e30;
|
background: var(--border-color);
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
|
@ -503,9 +574,9 @@ ul {
|
||||||
}
|
}
|
||||||
|
|
||||||
.markdown-body blockquote {
|
.markdown-body blockquote {
|
||||||
border-left: 4px solid #00b0f4;
|
border-left: 4px solid var(--link-color);
|
||||||
padding-left: 1rem;
|
padding-left: 1rem;
|
||||||
color: #aaa;
|
color: var(--blockquote-color);
|
||||||
margin: 1rem 0;
|
margin: 1rem 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
/* eslint-disable indent */
|
|
||||||
|
|
||||||
const activityProgressMap = new Map();
|
const activityProgressMap = new Map();
|
||||||
|
|
||||||
function formatTime(ms) {
|
function formatTime(ms) {
|
||||||
|
@ -23,19 +21,19 @@ function formatVerbose(ms) {
|
||||||
function updateElapsedAndProgress() {
|
function updateElapsedAndProgress() {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
|
|
||||||
document.querySelectorAll(".activity-timestamp").forEach((el) => {
|
for (const el of document.querySelectorAll(".activity-timestamp")) {
|
||||||
const start = Number(el.dataset.start);
|
const start = Number(el.dataset.start);
|
||||||
if (!start) return;
|
if (!start) continue;
|
||||||
|
|
||||||
const elapsed = now - start;
|
const elapsed = now - start;
|
||||||
const display = el.querySelector(".elapsed");
|
const display = el.querySelector(".elapsed");
|
||||||
if (display) display.textContent = `(${formatVerbose(elapsed)} ago)`;
|
if (display) display.textContent = `(${formatVerbose(elapsed)} ago)`;
|
||||||
});
|
}
|
||||||
|
|
||||||
document.querySelectorAll(".progress-bar").forEach((bar) => {
|
for (const bar of document.querySelectorAll(".progress-bar")) {
|
||||||
const start = Number(bar.dataset.start);
|
const start = Number(bar.dataset.start);
|
||||||
const end = Number(bar.dataset.end);
|
const end = Number(bar.dataset.end);
|
||||||
if (!start || !end || end <= start) return;
|
if (!start || !end || end <= start) continue;
|
||||||
|
|
||||||
const duration = end - start;
|
const duration = end - start;
|
||||||
const elapsed = Math.min(now - start, duration);
|
const elapsed = Math.min(now - start, duration);
|
||||||
|
@ -46,12 +44,12 @@ function updateElapsedAndProgress() {
|
||||||
|
|
||||||
const fill = bar.querySelector(".progress-fill");
|
const fill = bar.querySelector(".progress-fill");
|
||||||
if (fill) fill.style.width = `${progress}%`;
|
if (fill) fill.style.width = `${progress}%`;
|
||||||
});
|
}
|
||||||
|
|
||||||
document.querySelectorAll(".progress-time-labels").forEach((label) => {
|
for (const label of document.querySelectorAll(".progress-time-labels")) {
|
||||||
const start = Number(label.dataset.start);
|
const start = Number(label.dataset.start);
|
||||||
const end = Number(label.dataset.end);
|
const end = Number(label.dataset.end);
|
||||||
if (!start || !end || end <= start) return;
|
if (!start || !end || end <= start) continue;
|
||||||
|
|
||||||
const isPaused = now > end;
|
const isPaused = now > end;
|
||||||
const current = isPaused ? end - start : Math.max(0, now - start);
|
const current = isPaused ? end - start : Math.max(0, now - start);
|
||||||
|
@ -77,14 +75,14 @@ function updateElapsedAndProgress() {
|
||||||
: formatTime(current);
|
: formatTime(current);
|
||||||
}
|
}
|
||||||
if (totalEl) totalEl.textContent = formatTime(total);
|
if (totalEl) totalEl.textContent = formatTime(total);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateElapsedAndProgress();
|
updateElapsedAndProgress();
|
||||||
setInterval(updateElapsedAndProgress, 1000);
|
setInterval(updateElapsedAndProgress, 1000);
|
||||||
|
|
||||||
const head = document.querySelector("head");
|
const head = document.querySelector("head");
|
||||||
let userId = head?.dataset.userId;
|
const userId = head?.dataset.userId;
|
||||||
let instanceUri = head?.dataset.instanceUri;
|
let instanceUri = head?.dataset.instanceUri;
|
||||||
|
|
||||||
if (userId && instanceUri) {
|
if (userId && instanceUri) {
|
||||||
|
@ -132,6 +130,25 @@ if (userId && instanceUri) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resolveActivityImage(img, applicationId) {
|
||||||
|
if (!img) return null;
|
||||||
|
|
||||||
|
if (img.startsWith("mp:external/")) {
|
||||||
|
return `https://media.discordapp.net/external/${img.slice("mp:external/".length)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (img.includes("/https/")) {
|
||||||
|
const clean = img.split("/https/")[1];
|
||||||
|
return clean ? `https://${clean}` : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (img.startsWith("spotify:")) {
|
||||||
|
return `https://i.scdn.co/image/${img.split(":")[1]}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `https://cdn.discordapp.com/app-assets/${applicationId}/${img}.png`;
|
||||||
|
}
|
||||||
|
|
||||||
function buildActivityHTML(activity) {
|
function buildActivityHTML(activity) {
|
||||||
const start = activity.timestamps?.start;
|
const start = activity.timestamps?.start;
|
||||||
const end = activity.timestamps?.end;
|
const end = activity.timestamps?.end;
|
||||||
|
@ -143,18 +160,18 @@ function buildActivityHTML(activity) {
|
||||||
? Math.min(100, Math.floor((elapsed / total) * 100))
|
? Math.min(100, Math.floor((elapsed / total) * 100))
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
const img = activity.assets?.large_image;
|
|
||||||
let art = null;
|
let art = null;
|
||||||
|
let smallArt = null;
|
||||||
|
|
||||||
if (img?.startsWith("mp:external/")) {
|
if (activity.assets) {
|
||||||
art = `https://media.discordapp.net/external/${img.slice("mp:external/".length)}`;
|
art = resolveActivityImage(
|
||||||
} else if (img?.includes("/https/")) {
|
activity.assets.large_image,
|
||||||
const clean = img.split("/https/")[1];
|
activity.application_id,
|
||||||
if (clean) art = `https://${clean}`;
|
);
|
||||||
} else if (img?.startsWith("spotify:")) {
|
smallArt = resolveActivityImage(
|
||||||
art = `https://i.scdn.co/image/${img.split(":")[1]}`;
|
activity.assets.small_image,
|
||||||
} else if (img) {
|
activity.application_id,
|
||||||
art = `https://cdn.discordapp.com/app-assets/${activity.application_id}/${img}.png`;
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const activityTypeMap = {
|
const activityTypeMap = {
|
||||||
|
@ -189,10 +206,7 @@ function buildActivityHTML(activity) {
|
||||||
? `<div class="activity-buttons">
|
? `<div class="activity-buttons">
|
||||||
${activity.buttons
|
${activity.buttons
|
||||||
.map((button, index) => {
|
.map((button, index) => {
|
||||||
const label =
|
const label = typeof button === "string" ? button : button.label;
|
||||||
typeof button === "string"
|
|
||||||
? button
|
|
||||||
: button.label;
|
|
||||||
let url = null;
|
let url = null;
|
||||||
if (typeof button === "object" && button.url) {
|
if (typeof button === "object" && button.url) {
|
||||||
url = button.url;
|
url = button.url;
|
||||||
|
@ -225,6 +239,13 @@ function buildActivityHTML(activity) {
|
||||||
const secondaryLine = isMusic ? activity.state : activity.details;
|
const secondaryLine = isMusic ? activity.state : activity.details;
|
||||||
const tertiaryLine = isMusic ? activity.assets?.large_text : activity.state;
|
const tertiaryLine = isMusic ? activity.assets?.large_text : activity.state;
|
||||||
|
|
||||||
|
const activityArt = art
|
||||||
|
? `<div class="activity-image-wrapper">
|
||||||
|
<img class="activity-image" src="${art}" alt="Art" ${activity.assets?.large_text ? `title="${activity.assets.large_text}"` : ""}>
|
||||||
|
${smallArt ? `<img class="activity-image-small" src="${smallArt}" alt="Small Art" ${activity.assets?.small_text ? `title="${activity.assets.small_text}"` : ""}>` : ""}
|
||||||
|
</div>`
|
||||||
|
: "";
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<li class="activity">
|
<li class="activity">
|
||||||
<div class="activity-wrapper">
|
<div class="activity-wrapper">
|
||||||
|
@ -233,7 +254,7 @@ function buildActivityHTML(activity) {
|
||||||
${activityTimestamp}
|
${activityTimestamp}
|
||||||
</div>
|
</div>
|
||||||
<div class="activity-wrapper-inner">
|
<div class="activity-wrapper-inner">
|
||||||
${art ? `<img class="activity-art" src="${art}" alt="Art">` : ""}
|
${activityArt}
|
||||||
<div class="activity-content">
|
<div class="activity-content">
|
||||||
<div class="inner-content">
|
<div class="inner-content">
|
||||||
<div class="activity-top">
|
<div class="activity-top">
|
||||||
|
@ -258,9 +279,7 @@ function buildActivityHTML(activity) {
|
||||||
function updatePresence(data) {
|
function updatePresence(data) {
|
||||||
const avatarWrapper = document.querySelector(".avatar-wrapper");
|
const avatarWrapper = document.querySelector(".avatar-wrapper");
|
||||||
const statusIndicator = avatarWrapper?.querySelector(".status-indicator");
|
const statusIndicator = avatarWrapper?.querySelector(".status-indicator");
|
||||||
const mobileIcon = avatarWrapper?.querySelector(
|
const mobileIcon = avatarWrapper?.querySelector(".platform-icon.mobile-only");
|
||||||
".platform-icon.mobile-only",
|
|
||||||
);
|
|
||||||
|
|
||||||
const userInfo = document.querySelector(".user-info");
|
const userInfo = document.querySelector(".user-info");
|
||||||
const customStatus = userInfo?.querySelector(".custom-status");
|
const customStatus = userInfo?.querySelector(".custom-status");
|
||||||
|
@ -271,8 +290,16 @@ function updatePresence(data) {
|
||||||
desktop: data.active_on_discord_desktop,
|
desktop: data.active_on_discord_desktop,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let status = "offline";
|
||||||
|
console.log(data.activities.some((activity) => activity.type === 1));
|
||||||
|
if (data.activities.some((activity) => activity.type === 1)) {
|
||||||
|
status = "streaming";
|
||||||
|
} else {
|
||||||
|
status = data.discord_status;
|
||||||
|
}
|
||||||
|
|
||||||
if (statusIndicator) {
|
if (statusIndicator) {
|
||||||
statusIndicator.className = `status-indicator ${data.discord_status}`;
|
statusIndicator.className = `status-indicator ${status}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (platform.mobile && !mobileIcon) {
|
if (platform.mobile && !mobileIcon) {
|
||||||
|
@ -283,7 +310,7 @@ function updatePresence(data) {
|
||||||
`;
|
`;
|
||||||
} else if (!platform.mobile && mobileIcon) {
|
} else if (!platform.mobile && mobileIcon) {
|
||||||
mobileIcon.remove();
|
mobileIcon.remove();
|
||||||
avatarWrapper.innerHTML += `<div class="status-indicator ${data.discord_status}"></div>`;
|
avatarWrapper.innerHTML += `<div class="status-indicator ${status}"></div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const custom = data.activities?.find((a) => a.type === 4);
|
const custom = data.activities?.find((a) => a.type === 4);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
export function timestampToReadable(timestamp?: number): string {
|
export function timestampToReadable(timestamp?: number): string {
|
||||||
const date: Date =
|
const date: Date =
|
||||||
timestamp && !isNaN(timestamp) ? new Date(timestamp) : new Date();
|
timestamp && !Number.isNaN(timestamp) ? new Date(timestamp) : new Date();
|
||||||
if (isNaN(date.getTime())) return "Invalid Date";
|
if (Number.isNaN(date.getTime())) return "Invalid Date";
|
||||||
return date.toISOString().replace("T", " ").replace("Z", "");
|
return date.toISOString().replace("T", " ").replace("Z", "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
import { resolve } from "node:path";
|
||||||
import { renderFile } from "ejs";
|
import { renderFile } from "ejs";
|
||||||
import { resolve } from "path";
|
|
||||||
|
|
||||||
export async function renderEjsTemplate(
|
export async function renderEjsTemplate(
|
||||||
viewName: string | string[],
|
viewName: string | string[],
|
||||||
|
|
|
@ -76,7 +76,7 @@ export async function handleReadMe(data: LanyardData): Promise<string | null> {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (res.headers.has("content-length")) {
|
if (res.headers.has("content-length")) {
|
||||||
const size: number = parseInt(
|
const size: number = Number.parseInt(
|
||||||
res.headers.get("content-length") || "0",
|
res.headers.get("content-length") || "0",
|
||||||
10,
|
10,
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import { environment } from "@config/environment";
|
import type { Stats } from "node:fs";
|
||||||
import { timestampToReadable } from "@helpers/char";
|
|
||||||
import type { Stats } from "fs";
|
|
||||||
import {
|
import {
|
||||||
|
type WriteStream,
|
||||||
createWriteStream,
|
createWriteStream,
|
||||||
existsSync,
|
existsSync,
|
||||||
mkdirSync,
|
mkdirSync,
|
||||||
statSync,
|
statSync,
|
||||||
WriteStream,
|
} from "node:fs";
|
||||||
} from "fs";
|
import { EOL } from "node:os";
|
||||||
import { EOL } from "os";
|
import { basename, join } from "node:path";
|
||||||
import { basename, join } from "path";
|
import { environment } from "@config/environment";
|
||||||
|
import { timestampToReadable } from "@helpers/char";
|
||||||
|
|
||||||
class Logger {
|
class Logger {
|
||||||
private static instance: Logger;
|
private static instance: Logger;
|
||||||
|
@ -37,7 +37,7 @@ class Logger {
|
||||||
mkdirSync(logDir, { recursive: true });
|
mkdirSync(logDir, { recursive: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
let addSeparator: boolean = false;
|
let addSeparator = false;
|
||||||
|
|
||||||
if (existsSync(logFile)) {
|
if (existsSync(logFile)) {
|
||||||
const fileStats: Stats = statSync(logFile);
|
const fileStats: Stats = statSync(logFile);
|
||||||
|
@ -66,9 +66,9 @@ class Logger {
|
||||||
|
|
||||||
private extractFileName(stack: string): string {
|
private extractFileName(stack: string): string {
|
||||||
const stackLines: string[] = stack.split("\n");
|
const stackLines: string[] = stack.split("\n");
|
||||||
let callerFile: string = "";
|
let callerFile = "";
|
||||||
|
|
||||||
for (let i: number = 2; i < stackLines.length; i++) {
|
for (let i = 2; i < stackLines.length; i++) {
|
||||||
const line: string = stackLines[i].trim();
|
const line: string = stackLines[i].trim();
|
||||||
if (line && !line.includes("Logger.") && line.includes("(")) {
|
if (line && !line.includes("Logger.") && line.includes("(")) {
|
||||||
callerFile = line.split("(")[1]?.split(")")[0] || "";
|
callerFile = line.split("(")[1]?.split(")")[0] || "";
|
||||||
|
@ -91,7 +91,7 @@ class Logger {
|
||||||
return { filename, timestamp: readableTimestamp };
|
return { filename, timestamp: readableTimestamp };
|
||||||
}
|
}
|
||||||
|
|
||||||
public info(message: string | string[], breakLine: boolean = false): void {
|
public info(message: string | string[], breakLine = false): void {
|
||||||
const stack: string = new Error().stack || "";
|
const stack: string = new Error().stack || "";
|
||||||
const { filename, timestamp } = this.getCallerInfo(stack);
|
const { filename, timestamp } = this.getCallerInfo(stack);
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ class Logger {
|
||||||
this.writeConsoleMessageColored(logMessageParts, breakLine);
|
this.writeConsoleMessageColored(logMessageParts, breakLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
public warn(message: string | string[], breakLine: boolean = false): void {
|
public warn(message: string | string[], breakLine = false): void {
|
||||||
const stack: string = new Error().stack || "";
|
const stack: string = new Error().stack || "";
|
||||||
const { filename, timestamp } = this.getCallerInfo(stack);
|
const { filename, timestamp } = this.getCallerInfo(stack);
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ class Logger {
|
||||||
|
|
||||||
public error(
|
public error(
|
||||||
message: string | Error | (string | Error)[],
|
message: string | Error | (string | Error)[],
|
||||||
breakLine: boolean = false,
|
breakLine = false,
|
||||||
): void {
|
): void {
|
||||||
const stack: string = new Error().stack || "";
|
const stack: string = new Error().stack || "";
|
||||||
const { filename, timestamp } = this.getCallerInfo(stack);
|
const { filename, timestamp } = this.getCallerInfo(stack);
|
||||||
|
@ -161,7 +161,7 @@ class Logger {
|
||||||
bracketMessage2: string,
|
bracketMessage2: string,
|
||||||
message: string | string[],
|
message: string | string[],
|
||||||
color: string,
|
color: string,
|
||||||
breakLine: boolean = false,
|
breakLine = false,
|
||||||
): void {
|
): void {
|
||||||
const stack: string = new Error().stack || "";
|
const stack: string = new Error().stack || "";
|
||||||
const { timestamp } = this.getCallerInfo(stack);
|
const { timestamp } = this.getCallerInfo(stack);
|
||||||
|
@ -189,7 +189,7 @@ class Logger {
|
||||||
|
|
||||||
private writeConsoleMessageColored(
|
private writeConsoleMessageColored(
|
||||||
logMessageParts: ILogMessageParts,
|
logMessageParts: ILogMessageParts,
|
||||||
breakLine: boolean = false,
|
breakLine = false,
|
||||||
): void {
|
): void {
|
||||||
const logMessage: string = Object.keys(logMessageParts)
|
const logMessage: string = Object.keys(logMessageParts)
|
||||||
.map((key: string) => {
|
.map((key: string) => {
|
||||||
|
|
|
@ -3,11 +3,7 @@ import { logger } from "@helpers/logger";
|
||||||
import { serverHandler } from "@/server";
|
import { serverHandler } from "@/server";
|
||||||
|
|
||||||
async function main(): Promise<void> {
|
async function main(): Promise<void> {
|
||||||
try {
|
serverHandler.initialize();
|
||||||
serverHandler.initialize();
|
|
||||||
} catch (error) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main().catch((error: Error) => {
|
main().catch((error: Error) => {
|
||||||
|
|
|
@ -29,13 +29,20 @@ async function handler(request: ExtendedRequest): Promise<Response> {
|
||||||
}
|
}
|
||||||
|
|
||||||
const presence: LanyardData = data.data;
|
const presence: LanyardData = data.data;
|
||||||
const readme: string | Promise<string> | null =
|
const readme: string | Promise<string> | null = await handleReadMe(presence);
|
||||||
await handleReadMe(presence);
|
|
||||||
|
let status: string;
|
||||||
|
if (presence.activities.some((activity) => activity.type === 1)) {
|
||||||
|
status = "streaming";
|
||||||
|
} else {
|
||||||
|
status = presence.discord_status;
|
||||||
|
}
|
||||||
|
|
||||||
const ejsTemplateData: EjsTemplateData = {
|
const ejsTemplateData: EjsTemplateData = {
|
||||||
title: `${presence.discord_user.username || "Unknown"}`,
|
title: presence.discord_user.global_name || presence.discord_user.username,
|
||||||
username: presence.discord_user.username,
|
username:
|
||||||
status: presence.discord_status,
|
presence.discord_user.global_name || presence.discord_user.username,
|
||||||
|
status: status,
|
||||||
activities: presence.activities,
|
activities: presence.activities,
|
||||||
user: presence.discord_user,
|
user: presence.discord_user,
|
||||||
platform: {
|
platform: {
|
||||||
|
|
|
@ -24,10 +24,7 @@ async function handler(request: ExtendedRequest): Promise<Response> {
|
||||||
try {
|
try {
|
||||||
res = await fetch(url);
|
res = await fetch(url);
|
||||||
} catch {
|
} catch {
|
||||||
return Response.json(
|
return Response.json({ error: "Failed to fetch image" }, { status: 500 });
|
||||||
{ error: "Failed to fetch image" },
|
|
||||||
{ status: 500 },
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
|
|
|
@ -28,15 +28,20 @@ async function handler(): Promise<Response> {
|
||||||
}
|
}
|
||||||
|
|
||||||
const presence: LanyardData = data.data;
|
const presence: LanyardData = data.data;
|
||||||
const readme: string | Promise<string> | null =
|
const readme: string | Promise<string> | null = await handleReadMe(presence);
|
||||||
await handleReadMe(presence);
|
|
||||||
|
let status: string;
|
||||||
|
if (presence.activities.some((activity) => activity.type === 1)) {
|
||||||
|
status = "streaming";
|
||||||
|
} else {
|
||||||
|
status = presence.discord_status;
|
||||||
|
}
|
||||||
|
|
||||||
const ejsTemplateData: EjsTemplateData = {
|
const ejsTemplateData: EjsTemplateData = {
|
||||||
title:
|
title: presence.discord_user.global_name || presence.discord_user.username,
|
||||||
presence.discord_user.global_name || presence.discord_user.username,
|
|
||||||
username:
|
username:
|
||||||
presence.discord_user.global_name || presence.discord_user.username,
|
presence.discord_user.global_name || presence.discord_user.username,
|
||||||
status: presence.discord_status,
|
status: status,
|
||||||
activities: presence.activities,
|
activities: presence.activities,
|
||||||
user: presence.discord_user,
|
user: presence.discord_user,
|
||||||
platform: {
|
platform: {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { resolve } from "node:path";
|
||||||
import { environment } from "@config/environment";
|
import { environment } from "@config/environment";
|
||||||
import { logger } from "@helpers/logger";
|
import { logger } from "@helpers/logger";
|
||||||
import {
|
import {
|
||||||
|
@ -6,7 +7,6 @@ import {
|
||||||
type MatchedRoute,
|
type MatchedRoute,
|
||||||
type Serve,
|
type Serve,
|
||||||
} from "bun";
|
} from "bun";
|
||||||
import { resolve } from "path";
|
|
||||||
|
|
||||||
import { webSocketHandler } from "@/websocket";
|
import { webSocketHandler } from "@/websocket";
|
||||||
|
|
||||||
|
@ -77,21 +77,16 @@ class ServerHandler {
|
||||||
|
|
||||||
if (await file.exists()) {
|
if (await file.exists()) {
|
||||||
const fileContent: ArrayBuffer = await file.arrayBuffer();
|
const fileContent: ArrayBuffer = await file.arrayBuffer();
|
||||||
const contentType: string =
|
const contentType: string = file.type || "application/octet-stream";
|
||||||
file.type || "application/octet-stream";
|
|
||||||
|
|
||||||
return new Response(fileContent, {
|
return new Response(fileContent, {
|
||||||
headers: { "Content-Type": contentType },
|
headers: { "Content-Type": contentType },
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
logger.warn(`File not found: ${filePath}`);
|
|
||||||
return new Response("Not Found", { status: 404 });
|
|
||||||
}
|
}
|
||||||
|
logger.warn(`File not found: ${filePath}`);
|
||||||
|
return new Response("Not Found", { status: 404 });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error([
|
logger.error([`Error serving static file: ${pathname}`, error as Error]);
|
||||||
`Error serving static file: ${pathname}`,
|
|
||||||
error as Error,
|
|
||||||
]);
|
|
||||||
return new Response("Internal Server Error", { status: 500 });
|
return new Response("Internal Server Error", { status: 500 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,8 +112,7 @@ class ServerHandler {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const routeModule: RouteModule = await import(filePath);
|
const routeModule: RouteModule = await import(filePath);
|
||||||
const contentType: string | null =
|
const contentType: string | null = request.headers.get("Content-Type");
|
||||||
request.headers.get("Content-Type");
|
|
||||||
const actualContentType: string | null = contentType
|
const actualContentType: string | null = contentType
|
||||||
? contentType.split(";")[0].trim()
|
? contentType.split(";")[0].trim()
|
||||||
: null;
|
: null;
|
||||||
|
@ -145,9 +139,7 @@ class ServerHandler {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(Array.isArray(routeModule.routeDef.method) &&
|
(Array.isArray(routeModule.routeDef.method) &&
|
||||||
!routeModule.routeDef.method.includes(
|
!routeModule.routeDef.method.includes(request.method)) ||
|
||||||
request.method,
|
|
||||||
)) ||
|
|
||||||
(!Array.isArray(routeModule.routeDef.method) &&
|
(!Array.isArray(routeModule.routeDef.method) &&
|
||||||
routeModule.routeDef.method !== request.method)
|
routeModule.routeDef.method !== request.method)
|
||||||
) {
|
) {
|
||||||
|
@ -172,9 +164,7 @@ class ServerHandler {
|
||||||
if (Array.isArray(expectedContentType)) {
|
if (Array.isArray(expectedContentType)) {
|
||||||
matchesAccepts =
|
matchesAccepts =
|
||||||
expectedContentType.includes("*/*") ||
|
expectedContentType.includes("*/*") ||
|
||||||
expectedContentType.includes(
|
expectedContentType.includes(actualContentType || "");
|
||||||
actualContentType || "",
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
matchesAccepts =
|
matchesAccepts =
|
||||||
expectedContentType === "*/*" ||
|
expectedContentType === "*/*" ||
|
||||||
|
@ -213,10 +203,7 @@ class ServerHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
logger.error([
|
logger.error([`Error handling route ${request.url}:`, error as Error]);
|
||||||
`Error handling route ${request.url}:`,
|
|
||||||
error as Error,
|
|
||||||
]);
|
|
||||||
|
|
||||||
response = Response.json(
|
response = Response.json(
|
||||||
{
|
{
|
||||||
|
|
|
@ -76,20 +76,32 @@
|
||||||
const total = (start && end) ? end - start : null;
|
const total = (start && end) ? end - start : null;
|
||||||
const progress = (total && elapsed > 0) ? Math.min(100, Math.floor((elapsed / total) * 100)) : null;
|
const progress = (total && elapsed > 0) ? Math.min(100, Math.floor((elapsed / total) * 100)) : null;
|
||||||
|
|
||||||
const img = activity.assets?.large_image;
|
|
||||||
let art = null;
|
let art = null;
|
||||||
|
let smallArt = null;
|
||||||
|
|
||||||
if (img?.startsWith("mp:external/")) {
|
function resolveActivityImage(img, applicationId) {
|
||||||
art = `https://media.discordapp.net/external/${img.slice("mp:external/".length)}`;
|
if (!img) return null;
|
||||||
} else if (img?.includes("/https/")) {
|
|
||||||
const clean = img.split("/https/")[1];
|
if (img.startsWith("mp:external/")) {
|
||||||
if (clean) art = `https://${clean}`;
|
return `https://media.discordapp.net/external/${img.slice("mp:external/".length)}`;
|
||||||
} else if (img?.startsWith("spotify:")) {
|
}
|
||||||
art = `https://i.scdn.co/image/${img.split(":")[1]}`;
|
|
||||||
} else if (img) {
|
if (img.includes("/https/")) {
|
||||||
art = `https://cdn.discordapp.com/app-assets/${activity.application_id}/${img}.png`;
|
const clean = img.split("/https/")[1];
|
||||||
|
return clean ? `https://${clean}` : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (img.startsWith("spotify:")) {
|
||||||
|
return `https://i.scdn.co/image/${img.split(":")[1]}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `https://cdn.discordapp.com/app-assets/${applicationId}/${img}.png`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (activity.assets) {
|
||||||
|
art = resolveActivityImage(activity.assets.large_image, activity.application_id);
|
||||||
|
smallArt = resolveActivityImage(activity.assets.small_image, activity.application_id);
|
||||||
|
}
|
||||||
|
|
||||||
const activityTypeMap = {
|
const activityTypeMap = {
|
||||||
0: "Playing",
|
0: "Playing",
|
||||||
|
@ -124,7 +136,12 @@
|
||||||
|
|
||||||
<div class="activity-wrapper-inner">
|
<div class="activity-wrapper-inner">
|
||||||
<% if (art) { %>
|
<% if (art) { %>
|
||||||
<img class="activity-art" src="<%= art %>" alt="Art">
|
<div class="activity-image-wrapper">
|
||||||
|
<img class="activity-image" src="<%= art %>" alt="Art" <% activity.assets?.large_text ? `title="${activity.assets.large_text}"` : '' %>>
|
||||||
|
<% if (smallArt) { %>
|
||||||
|
<img class="activity-image-small" src="<%= smallArt %>" alt="Small Art" <% activity.assets?.small_text ? `title="${activity.assets.small_text}"` : '' %>>
|
||||||
|
<% } %>
|
||||||
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
<div class="activity-content">
|
<div class="activity-content">
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { logger } from "@helpers/logger";
|
import { logger } from "@helpers/logger";
|
||||||
import { type ServerWebSocket } from "bun";
|
import type { ServerWebSocket } from "bun";
|
||||||
|
|
||||||
class WebSocketHandler {
|
class WebSocketHandler {
|
||||||
public handleMessage(ws: ServerWebSocket, message: string): void {
|
public handleMessage(ws: ServerWebSocket, message: string): void {
|
||||||
|
@ -20,11 +20,7 @@ class WebSocketHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public handleClose(
|
public handleClose(ws: ServerWebSocket, code: number, reason: string): void {
|
||||||
ws: ServerWebSocket,
|
|
||||||
code: number,
|
|
||||||
reason: string,
|
|
||||||
): void {
|
|
||||||
logger.warn(`WebSocket closed with code ${code}, reason: ${reason}`);
|
logger.warn(`WebSocket closed with code ${code}, reason: ${reason}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,28 +2,14 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"baseUrl": "./",
|
"baseUrl": "./",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": [
|
"@/*": ["src/*"],
|
||||||
"src/*"
|
"@config/*": ["config/*"],
|
||||||
],
|
"@types/*": ["types/*"],
|
||||||
"@config/*": [
|
"@helpers/*": ["src/helpers/*"]
|
||||||
"config/*"
|
|
||||||
],
|
|
||||||
"@types/*": [
|
|
||||||
"types/*"
|
|
||||||
],
|
|
||||||
"@helpers/*": [
|
|
||||||
"src/helpers/*"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"typeRoots": [
|
"typeRoots": ["./src/types", "./node_modules/@types"],
|
||||||
"./src/types",
|
|
||||||
"./node_modules/@types"
|
|
||||||
],
|
|
||||||
// Enable latest features
|
// Enable latest features
|
||||||
"lib": [
|
"lib": ["ESNext", "DOM"],
|
||||||
"ESNext",
|
|
||||||
"DOM"
|
|
||||||
],
|
|
||||||
"target": "ESNext",
|
"target": "ESNext",
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"moduleDetection": "force",
|
"moduleDetection": "force",
|
||||||
|
@ -41,11 +27,7 @@
|
||||||
// Some stricter flags (disabled by default)
|
// Some stricter flags (disabled by default)
|
||||||
"noUnusedLocals": false,
|
"noUnusedLocals": false,
|
||||||
"noUnusedParameters": false,
|
"noUnusedParameters": false,
|
||||||
"noPropertyAccessFromIndexSignature": false,
|
"noPropertyAccessFromIndexSignature": false
|
||||||
},
|
},
|
||||||
"include": [
|
"include": ["src", "types", "config"]
|
||||||
"src",
|
|
||||||
"types",
|
|
||||||
"config"
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue