29 lines
539 B
TypeScript
29 lines
539 B
TypeScript
import { cors } from "@elysiajs/cors";
|
|
import { Elysia, env } from "elysia";
|
|
import api from "./api";
|
|
import staticFiles from "./static";
|
|
import * as log from "./logging";
|
|
|
|
const port = env.PORT || 5001;
|
|
|
|
new Elysia()
|
|
.use(
|
|
cors({
|
|
origin: [
|
|
"http://localhost:3000", // dev
|
|
"https://games.drm.dev", // prod
|
|
],
|
|
})
|
|
)
|
|
|
|
.onRequest(({ request }) => log.log(request))
|
|
.onError(({ error }) => log.err(error))
|
|
|
|
.get("/ping", () => "pong")
|
|
.use(api)
|
|
.use(staticFiles)
|
|
|
|
.listen(port);
|
|
|
|
log.log(`server started on ${port}`);
|