Skip to content

Commit 5cfe0ce

Browse files
aster-voidclaude
andcommitted
treewide: add logger and auto db migration
- Add @bogeychan/elysia-logger for request logging - Add db:migrate script to server package.json - Configure devenv to run migrations before server starts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 448a7ce commit 5cfe0ce

File tree

5 files changed

+65
-296
lines changed

5 files changed

+65
-296
lines changed

apps/server/package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@
66
".": "./src/index.ts"
77
},
88
"scripts": {
9-
"test": "echo \"Error: no test specified\" && exit 1",
109
"dev": "bun run --watch src/index.ts",
11-
"check": "tsc --noEmit"
10+
"check": "tsc --noEmit",
11+
"db:migrate": "drizzle-kit migrate"
1212
},
1313
"dependencies": {
14+
"@bogeychan/elysia-logger": "^0.1.10",
15+
"@elysiajs/cors": "^1.4.0",
1416
"@elysiajs/jwt": "^1.4.0",
1517
"@sinclair/typebox": "^0.34.41",
1618
"drizzle-orm": "^0.45.0",
1719
"elysia": "^1.4.18",
18-
"postgres": "^3.4.7"
20+
"postgres": "^3.4.7",
21+
"valibot": "^1.2.0"
1922
},
2023
"devDependencies": {
2124
"bun-types": "latest",

apps/server/src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { cors } from "@elysiajs/cors";
12
import { Elysia } from "elysia";
23
import { authRoutes } from "./domains/auth/routes.ts";
34
import { channelRoutes } from "./domains/channels/routes.ts";
@@ -8,9 +9,13 @@ import { organizationRoutes } from "./domains/organizations/routes.ts";
89
import { taskRoutes } from "./domains/tasks/routes.ts";
910
import { userRoutes } from "./domains/users/routes.ts";
1011
import { voteRoutes } from "./domains/votes/routes.ts";
12+
import { env } from "./env.ts";
13+
import { loggerMiddleware } from "./middleware/logger.ts";
1114
import { wsRoutes } from "./ws/index.ts";
1215

1316
const app = new Elysia()
17+
.use(loggerMiddleware)
18+
.use(cors({ origin: env.CORS_ORIGIN, credentials: true }))
1419
.get("/", () => ({ message: "Prism API Server" }))
1520
.get("/health", () => ({ status: "ok", timestamp: Date.now() }))
1621
.use(authRoutes)
@@ -23,7 +28,7 @@ const app = new Elysia()
2328
.use(taskRoutes)
2429
.use(voteRoutes)
2530
.use(wsRoutes)
26-
.listen(3000);
31+
.listen(env.PORT);
2732

2833
console.log(
2934
`🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}`,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { logger } from "@bogeychan/elysia-logger";
2+
3+
export const loggerMiddleware = logger({
4+
level: process.env.NODE_ENV === "production" ? "info" : "debug",
5+
autoLogging: {
6+
ignore(ctx) {
7+
return ctx.path === "/health";
8+
},
9+
},
10+
});

0 commit comments

Comments
 (0)