-
Notifications
You must be signed in to change notification settings - Fork 52
/
index.ts
30 lines (24 loc) · 846 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import http from "http";
import path from "path";
import express from "express";
import { environment } from "../node/environment";
import { log } from "../node/utils/log";
import { getAssetsJSON } from "./common/get-assets-json";
import { registerRoutes } from "./register-routes";
export const server = () => {
const app = express()
.set("view engine", "ejs")
.use(express.static(".public"));
app.get("/", async (_req, res) => {
const assetsJSON = await getAssetsJSON();
res.render(path.join(__dirname, "../../views/index.ejs"), { assetsJSON });
});
registerRoutes(app);
const { SERVER_PORT } = environment();
return new Promise<http.Server>((resolve) => {
const s = app.listen(SERVER_PORT, () => {
log.success(`Started server at http://localhost:${SERVER_PORT}`);
resolve(s);
});
});
};