-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
32 lines (28 loc) · 850 Bytes
/
main.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
31
32
import express from "express";
import bodyParser from "body-parser";
import cors from "cors";
import { createMetaApplication } from "./application";
import { selfTest } from "./self-test";
import { setupRoutes } from "./routes";
export async function main() {
const expressApp = express();
expressApp.use(
cors({
exposedHeaders: ["X-Session-ID"],
})
);
expressApp.use(bodyParser.urlencoded({ extended: true }));
expressApp.use(bodyParser.json());
expressApp.use(bodyParser.json({ type: "application/vnd.api+json" }));
const metaApp = createMetaApplication();
setupRoutes(metaApp, expressApp);
const port = 3031;
expressApp.listen(port);
console.log(`Backend listening on port ${port}`);
if (process.env.SELF_TEST === "true") {
await selfTest(expressApp);
}
}
if (require.main === module) {
main();
}