refactor: replace proxy-based analytics with static guild datasets

This commit is contained in:
Meghdad committed 2026-10-20 17:15:10 +03:30
1 parent d95898cd1a
commit f9a8f5fd95
19 files changed
+397 -178

No files matched your search

+1 -7
View File
@@ -2,18 +2,12 @@ import http from 'node:http';
import { readFile, stat } from 'node:fs/promises';
import { resolve, extname, sep } from 'node:path';
import { spawnSync } from 'node:child_process';
import { proxyAlbion } from './albion-proxy.mjs';
const built = spawnSync(process.execPath, ['scripts/build.mjs'], { stdio:'inherit' });
if (built.status) process.exit(built.status);
const root=resolve('dist');
const types={'.html':'text/html; charset=utf-8','.css':'text/css','.js':'text/javascript','.jpg':'image/jpeg','.png':'image/png','.webp':'image/webp','.svg':'image/svg+xml','.xml':'application/xml','.txt':'text/plain'};
const types={'.json':'application/json; charset=utf-8','.html':'text/html; charset=utf-8','.css':'text/css','.js':'text/javascript','.jpg':'image/jpeg','.png':'image/png','.webp':'image/webp','.svg':'image/svg+xml','.xml':'application/xml','.txt':'text/plain'};
http.createServer(async(req,res)=>{
try {
if (new URL(req.url,'http://localhost').pathname.startsWith('/api/albion/')) {
const response = await proxyAlbion(new Request(new URL(req.url,'http://localhost'), { method: req.method }));
res.writeHead(response.status, Object.fromEntries(response.headers)).end(Buffer.from(await response.arrayBuffer()));
return;
}
let path=resolve(root, '.'+decodeURIComponent(new URL(req.url,'http://localhost').pathname));
if(path!==root && !path.startsWith(root+sep)){res.writeHead(403).end();return;}
if((await stat(path)).isDirectory()) path=resolve(path,'index.html');