-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
31 lines (23 loc) · 1008 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
31
import cors from "cors";
import express from "express";
import * as https from "https";
import * as fs from "fs";
import { config } from "config";
import { DatabaseIndexer } from "~~/databaseindexer";
import { MasterCalAPIController } from "~~/controllers/mastercalapi.controller";
import { MasterCalMainPageController } from "~~/controllers/mastercalmainpage.controller";
import { logger } from "~~/utils/Logger";
const app = express();
app.use(cors());
app.use(logger);
app.use("/", MasterCalMainPageController);
app.use("/api", MasterCalAPIController);
const certificate = fs.readFileSync("/etc/letsencrypt/live/mastercal.xyz/fullchain.pem");
const privateKey = fs.readFileSync("/etc/letsencrypt/live/mastercal.xyz/privkey.pem");
DatabaseIndexer.init().then(() => {
const httpsServer = https.createServer({
cert: certificate,
key: privateKey,
}, app);
httpsServer.listen(config.PORT, () => console.log(`Running api on https://${ config.HOST }:${ config.PORT }/`));
});