|
@@ -11,7 +11,6 @@ import methodOverride from 'method-override';
|
|
|
import helmet from 'helmet';
|
|
import helmet from 'helmet';
|
|
|
import { Express } from 'express';
|
|
import { Express } from 'express';
|
|
|
import expressBunyanLogger from 'express-bunyan-logger';
|
|
import expressBunyanLogger from 'express-bunyan-logger';
|
|
|
-import gracefulExit from 'express-graceful-exit';
|
|
|
|
|
|
|
|
|
|
import { ConnectionOptions, getConnectionManager } from 'typeorm';
|
|
import { ConnectionOptions, getConnectionManager } from 'typeorm';
|
|
|
import { createTerminus } from '@godaddy/terminus';
|
|
import { createTerminus } from '@godaddy/terminus';
|
|
@@ -125,19 +124,11 @@ export class Server {
|
|
|
if (serverUri === undefined) {
|
|
if (serverUri === undefined) {
|
|
|
throw new Error('The environment variable \'SERVER_URI\' must be defined.');
|
|
throw new Error('The environment variable \'SERVER_URI\' must be defined.');
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- const server = this.injector.get<HttpServer>(HttpServer);
|
|
|
|
|
-
|
|
|
|
|
- // init express-graceful-exit
|
|
|
|
|
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
|
|
|
- gracefulExit.init(server!);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$beforeRoutesInit(): void {
|
|
$beforeRoutesInit(): void {
|
|
|
- const expressApp = this.app.getApp();
|
|
|
|
|
|
|
|
|
|
this.app
|
|
this.app
|
|
|
- .use(gracefulExit.middleware(expressApp))
|
|
|
|
|
.use(cookieParser())
|
|
.use(cookieParser())
|
|
|
.use(compress({}))
|
|
.use(compress({}))
|
|
|
.use(methodOverride())
|
|
.use(methodOverride())
|
|
@@ -164,8 +155,6 @@ export class Server {
|
|
|
const connectionManager = getConnectionManager();
|
|
const connectionManager = getConnectionManager();
|
|
|
const defaultConnection = connectionManager.get('default');
|
|
const defaultConnection = connectionManager.get('default');
|
|
|
await defaultConnection.close();
|
|
await defaultConnection.close();
|
|
|
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
|
|
|
- // gracefulExit.gracefulExitHandler(expressApp, server!);
|
|
|
|
|
},
|
|
},
|
|
|
onShutdown: async() => {
|
|
onShutdown: async() => {
|
|
|
logger.info('cleanup finished, server is shutting down');
|
|
logger.info('cleanup finished, server is shutting down');
|