Files
games/packages/server/src/index.ts
2025-08-25 18:36:59 -04:00

34 lines
695 B
TypeScript

import { cors } from "@elysiajs/cors";
import { staticPlugin } from "@elysiajs/static";
import { Elysia, env } from "elysia";
import api from "./api";
const port = env.PORT || 5001;
const app = new Elysia()
.use(
cors({
origin: ["http://localhost:3000", "https://games.drm.dev"],
})
)
// .onRequest(({ request }) => {
// console.log(request.method, request.url);
// })
.onError(({ error }) => {
console.error(error);
return error;
})
.get("/ping", () => "pong")
.use(api)
.get("/*", () => Bun.file("./public/index.html"))
.use(
staticPlugin({
assets: "public",
prefix: "/",
alwaysStatic: true,
})
)
.listen(port);
console.log("server started on", port);