-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalytics-server.main.ts
39 lines (31 loc) · 1.01 KB
/
analytics-server.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
33
34
35
36
37
38
39
/**
* @description holds server main
*/
import { DebugLogUtil, UsageUtil } from '@open-template-hub/common';
import bodyParser from 'body-parser';
import cors from 'cors';
import dotenv from 'dotenv';
import express from 'express';
import { Routes } from './app/route/index.route';
const debugLogUtil = new DebugLogUtil();
// use .env file
const env = dotenv.config();
debugLogUtil.log( env.parsed );
// express init
const app: express.Application = express();
// public files
app.use( express.static( 'public' ) );
// parse application/json
app.use( bodyParser.urlencoded( { extended: false } ) );
app.use( bodyParser.json() );
app.use( cors() );
// mount routes
Routes.mount( app );
// listen port
const port: string = process.env.PORT || ( '4005' as string );
app.listen( port, () => {
console.info( 'Analytics Server is running on port: ', port );
const usageUtil = new UsageUtil();
const memoryUsage = usageUtil.getMemoryUsage();
console.info( `Startup Memory Usage: ${ memoryUsage.toFixed( 2 ) } MB` );
} );