From bb7e19c3e0d1eac5141b79c9a289989f709246eb Mon Sep 17 00:00:00 2001 From: "Dennis (via Claude+Gemma)" Date: Sat, 23 May 2026 04:26:32 +0200 Subject: [PATCH] gemma: generate apps/api/src/index.ts --- apps/api/src/index.ts | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 apps/api/src/index.ts diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts new file mode 100644 index 0000000..65a614c --- /dev/null +++ b/apps/api/src/index.ts @@ -0,0 +1,41 @@ +import "dotenv/config" +import Fastify from "fastify" +import cors from "@fastify/cors" +import cookie from "@fastify/cookie" +import jwt from "@fastify/jwt" +import { setupRoutes } from "./routes/index" + +const server = Fastify({ + logger: true +}) + +const PORT = Number(process.env.PORT) || 4001 +const HOST = "0.0.0.0" + +async function start() { + await server.register(cors, { + origin: "http://localhost:5174", + credentials: true + }) + + await server.register(cookie) + + await server.register(jwt, { + secret: process.env.JWT_SECRET || "dev-secret-change-me" + }) + + server.get("/health", async () => { + return { status: "ok" } + }) + + await setupRoutes(server) + + try { + await server.listen({ port: PORT, host: HOST }) + } catch (err) { + server.log.error(err) + process.exit(1) + } +} + +start() \ No newline at end of file