@trayio/express 5.9.0 → 5.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,7 @@ interface ExpressServerOptions {
5
5
  port?: number;
6
6
  shutdownTimeoutMillis?: number;
7
7
  shutdownDelayMillis?: number;
8
+ customShutdownHook?: () => undefined;
8
9
  }
9
10
  export declare const startServer: (controllers: ExpressHttpController[], options: ExpressServerOptions) => http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
10
11
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"ExpressHttpServer.d.ts","sourceRoot":"","sources":["../../src/http/ExpressHttpServer.ts"],"names":[],"mappings":";AAEA,OAAO,IAAI,GAAG,QAAQ,MAAM,CAAC,CAAC;AAE9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,UAAU,oBAAoB;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,eAAO,MAAM,WAAW,gBACV,qBAAqB,EAAE,WAC3B,oBAAoB,yEAyD7B,CAAC"}
1
+ {"version":3,"file":"ExpressHttpServer.d.ts","sourceRoot":"","sources":["../../src/http/ExpressHttpServer.ts"],"names":[],"mappings":";AAEA,OAAO,IAAI,GAAG,QAAQ,MAAM,CAAC,CAAC;AAE9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,UAAU,oBAAoB;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,SAAS,CAAC;CACrC;AAED,eAAO,MAAM,WAAW,gBACV,qBAAqB,EAAE,WAC3B,oBAAoB,yEA2D7B,CAAC"}
@@ -23,21 +23,23 @@ const startServer = (controllers, options) => {
23
23
  const server = app.listen(port, () => {
24
24
  console.log(`Web server listening on port ${port}`);
25
25
  });
26
- process.on('SIGTERM', () => {
27
- console.log('Received kill signal, shutting down gracefully...');
28
- server.close(() => {
29
- const shutdownDelayMillis = options.shutdownDelayMillis || 500;
30
- console.log(`Closed out remaining connections. Waiting for shutdown delay of ${shutdownDelayMillis}ms before exiting.`);
26
+ const shutdownHook = options.customShutdownHook
27
+ ? process.on('SIGTERM', options.customShutdownHook)
28
+ : process.on('SIGTERM', () => {
29
+ console.log('Received kill signal, shutting down gracefully...');
30
+ server.close(() => {
31
+ const shutdownDelayMillis = options.shutdownDelayMillis || 500;
32
+ console.log(`Closed out remaining connections. Waiting for shutdown delay of ${shutdownDelayMillis}ms before exiting.`);
33
+ setTimeout(() => {
34
+ process.exit(0);
35
+ }, shutdownDelayMillis);
36
+ });
37
+ // If after 10 seconds, forcefully shut down
31
38
  setTimeout(() => {
32
- process.exit(0);
33
- }, shutdownDelayMillis);
39
+ console.error('Could not close connections in time, forcefully shutting down');
40
+ process.exit(1);
41
+ }, options.shutdownTimeoutMillis || 10000);
34
42
  });
35
- // If after 10 seconds, forcefully shut down
36
- setTimeout(() => {
37
- console.error('Could not close connections in time, forcefully shutting down');
38
- process.exit(1);
39
- }, options.shutdownTimeoutMillis || 10000);
40
- });
41
43
  return server;
42
44
  };
43
45
  exports.startServer = startServer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayio/express",
3
- "version": "5.9.0",
3
+ "version": "5.11.0",
4
4
  "description": "Express extensions and implementations",
5
5
  "exports": {
6
6
  "./*": "./dist/*.js"
@@ -14,7 +14,7 @@
14
14
  "access": "public"
15
15
  },
16
16
  "dependencies": {
17
- "@trayio/commons": "5.9.0",
17
+ "@trayio/commons": "5.11.0",
18
18
  "cors": "2.8.5",
19
19
  "express": "4.20.0",
20
20
  "formidable": "3.5.1"