initial commit

This commit is contained in:
Syahdan 2026-04-29 17:01:16 +07:00
commit 33e75c056f
77 changed files with 4329 additions and 0 deletions

37
apps/server/src/index.ts Normal file
View file

@ -0,0 +1,37 @@
import { cors } from "@elysiajs/cors";
import { createContext } from "@minmon/api/context";
import { appRouter } from "@minmon/api/routers/index";
import { auth } from "@minmon/auth";
import { env } from "@minmon/env/server";
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
import { Elysia } from "elysia";
const app = new Elysia()
.use(
cors({
origin: env.CORS_ORIGIN,
methods: ["GET", "POST", "OPTIONS"],
allowedHeaders: ["Content-Type", "Authorization"],
credentials: true,
}),
)
.all("/api/auth/*", async (context) => {
const { request, status } = context;
if (["POST", "GET"].includes(request.method)) {
return auth.handler(request);
}
return status(405);
})
.all("/trpc/*", async (context) => {
const res = await fetchRequestHandler({
endpoint: "/trpc",
router: appRouter,
req: context.request,
createContext: () => createContext({ context }),
});
return res;
})
.get("/", () => "OK")
.listen(3000, () => {
console.log("Server is running on http://localhost:3000");
});