-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
40 lines (36 loc) · 1.25 KB
/
index.ts
File metadata and controls
40 lines (36 loc) · 1.25 KB
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
33
34
35
36
37
38
39
40
import dotenv, { DotenvConfigOutput } from 'dotenv'; dotenv.config();
import { conexion } from './src/services/mongoose.service';
import { AppServer } from './src/app';
import { Logger } from './src/services/winston.service';
/**
* @author Antonio Olvera
* @description init application server
*/
class InitApplication {
constructor() {
this.initServer();
}
public static initEnviroment(): DotenvConfigOutput {
return dotenv.config();
}
private initServer(): void {
const _PORT: number = Number(process.env.PORT) || 4001;
const APP: AppServer = new AppServer();
APP.server.listen(_PORT, () => Logger.info(`Starting API Server - Server Running on Port ${_PORT}`));
}
}
(async () => {
try {
// Init enviroment
Logger.info('Starting API Server - Initialize enviroment variables');
InitApplication.initEnviroment();
// Init Database
Logger.info('Starting API Server - Initialize database conexion');
await conexion();
// Init server application
Logger.info('Starting API Server - Initialize application server');
new InitApplication();
} catch (error) {
Logger.error('Error at initialize server: ', error);
}
})();