-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
32 lines (28 loc) · 951 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
32
import dotenv from "dotenv";
dotenv.config();
import morgan from "morgan";
import {urlencoded} from "body-parser";
import cors from "cors";
import slackErrors from "./common/SendSlack";
// express
import express, { RequestHandler } from "express";
// important typings
import Server from "./common/Server";
import Controller from "./Controllers/Controller";
import AuthController from "./Controllers/Auth.Controller";
const controllers: Array<Controller> = [new AuthController()];
const globalMiddleware: Array<RequestHandler> = [
express.json(),
urlencoded({ extended: false }),
cors({ origin: true }),
morgan("combined"),
];
const PORT: number = Number(process.env.PORT!);
const server: Server = new Server(PORT, `${process.env.DB_URL}`);
Promise.resolve()
.then(() => server.initDatabase())
.then(() => {
server.loadMiddleware(globalMiddleware);
server.loadControllers(controllers);
const httpServer = server.run();
});