forked from pinks/eris
1
0
Fork 0
nyx/api/mod.ts

23 lines
646 B
TypeScript
Raw Normal View History

2023-10-05 09:00:51 +00:00
import { route } from "reroute";
import { serveSpa } from "serve_spa";
2023-10-08 21:23:54 +00:00
import { serveApi } from "./serveApi.ts";
2023-10-05 09:00:51 +00:00
export async function serveUi() {
const server = Deno.serve({ port: 5999 }, (request) =>
route(request, {
2023-10-08 21:23:54 +00:00
"/api/*": (request) => serveApi(request),
2023-10-05 09:00:51 +00:00
"/*": (request) =>
serveSpa(request, {
fsRoot: new URL("../ui/", import.meta.url).pathname,
indexFallback: true,
importMapFile: "../deno.json",
aliasMap: {
"/utils/*": "../utils/",
2023-09-26 10:43:36 +00:00
},
2023-10-09 19:03:31 +00:00
log: (_request, response) => response.status >= 400,
2023-10-05 09:00:51 +00:00
}),
}));
2023-09-26 10:43:36 +00:00
await server.finished;
}