improve http-graceful-shutdown - library should also support https servers (#27028)

* improve http-graceful-shutdown - library should also support https servers, widen typings to accomodate

* fix test file

* tiny test change to kick off the build, makes it easier to tell what the first parameter is anyway
This commit is contained in:
Dave
2018-07-03 15:39:23 -07:00
committed by Mohamed Hegazy
parent 8b168f1411
commit ade7469111
2 changed files with 14 additions and 4 deletions
@@ -1,5 +1,6 @@
import GracefulShutdown = require('http-graceful-shutdown');
import * as http from "http";
import * as https from "https";
const opts: GracefulShutdown.Options = {
signals: "SIGINT SIGTERM",
@@ -14,8 +15,16 @@ const opts: GracefulShutdown.Options = {
}
};
const server = http.createServer((req, res) => {
const httpServer = http.createServer((req, res) => {
res.end();
});
GracefulShutdown(server, opts);
const httpsServer = https.createServer({
key: new Buffer('foo'),
cert: new Buffer('bar')
}, (req, res) => {
res.end();
});
GracefulShutdown(httpServer, opts);
GracefulShutdown(httpsServer, opts);
+3 -2
View File
@@ -5,9 +5,10 @@
/// <reference types="node" />
import { Server } from "http";
import { Server as HttpServer } from "http";
import { Server as HttpsServer } from "https";
declare function GracefulShutdown(server: Server, options?: GracefulShutdown.Options): void;
declare function GracefulShutdown(server: HttpServer | HttpsServer, options?: GracefulShutdown.Options): void;
declare namespace GracefulShutdown {
interface Options {