Replace REST module routers with a single typed tRPC appRouter served over
/trpc (HTTP + WebSocket), and rewire the frontend to call it via
@trpc/client wsLink (browser) and httpLink (RSC data layer). Existing
/api/health + /api/metrics stay as plain Express for infra scraping.
Notable fixes surfaced by the live smoke test:
- Express 5 / path-to-regexp v8 rejects the /trpc/* wildcard route; use a
prefix middleware that computes opts.path from the URL instead.
- nodeHTTPRequestHandler treats opts.path as the literal procedure path, so
it is derived per-request from req.url.
- Two ws servers on one http.Server (the /ws voice socket + /trpc) collided
and returned 400 on upgrade; both now use noServer + a manually routed
server.on('upgrade') keyed by path.
Verified: BE tsc+biome+40 vitest green; FE tsc+biome green; live
HTTP and WebSocket calls returned real prod data.
Co-Authored-By: Claude Opus 4.5 (1M context) <noreply@anthropic.com>
42 lines
1.0 KiB
JSON
42 lines
1.0 KiB
JSON
{
|
|
"name": "discord-moderation-backend",
|
|
"version": "1.0.0",
|
|
"description": "Backend service for Discord moderation monitoring",
|
|
"type": "module",
|
|
"main": "dist/index.js",
|
|
"scripts": {
|
|
"dev": "tsx watch src/index.ts",
|
|
"start": "node dist/index.js",
|
|
"build": "tsc",
|
|
"typecheck": "tsc --noEmit",
|
|
"lint": "biome check --diagnostic-level=error .",
|
|
"format": "biome format --write .",
|
|
"test": "vitest run"
|
|
},
|
|
"dependencies": {
|
|
"@discordjs/voice": "^0.19.2",
|
|
"@trpc/server": "^11.18.0",
|
|
"axios": "^1.16.1",
|
|
"dotenv": "^17.4.2",
|
|
"drizzle-orm": "^0.45.2",
|
|
"express": "^5.2.1",
|
|
"helmet": "^8.1.0",
|
|
"ioredis": "^5.11.0",
|
|
"pg": "^8.21.0",
|
|
"pino": "^9.6.0",
|
|
"prom-client": "^15.1.3",
|
|
"ws": "^8.20.1",
|
|
"zod": "^4.4.3"
|
|
},
|
|
"devDependencies": {
|
|
"@biomejs/biome": "latest",
|
|
"@types/express": "^5.0.6",
|
|
"@types/node": "^25.9.0",
|
|
"@types/pg": "^8.20.0",
|
|
"@types/ws": "^8.18.1",
|
|
"tsx": "^4.22.2",
|
|
"typescript": "^5.9.3",
|
|
"vitest": "latest"
|
|
}
|
|
}
|