-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
31 lines (27 loc) · 921 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 "reflect-metadata";
import { Configurations } from './config';
import { Routes } from "./routes";
import express = require('express');
import { createConnection, getConnectionManager } from "typeorm";
const port = Configurations.port;
const uri = `localhost:${port}`;
const appInitialSetup = {
'environment': process.env.NODE_ENV,
"port:": Configurations.port,
hash: process.env.ShortHash
}
console.log(`App Initial Setup: ${JSON.stringify(appInitialSetup)}`);
const app = express();
app.use(express.urlencoded());
app.use(express.json());
app.listen(port, () => {
console.log(`Server ready at ${uri}`);
return getDbConnections().then(() => { Routes.call(app) });
});
async function getDbConnections() {
let connections = [];
if (!getConnectionManager().has('default')) {
await createConnection('default').then(() => console.log('created postgresDb connection'));
}
return connections;
}