Skip to content

Commit

Permalink
[[CHORE]] Add contributor and some clean-up tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseAntonioRodriguez committed Sep 23, 2016
1 parent c8d17c4 commit 129bc54
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 11 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ logs
node_modules

# TypeScript
/typings
/test/server-terminate.typings.js
2 changes: 0 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ node_modules

# TypeScript
tsconfig.json
typings.json
/typings
tslint.json

/test
Expand Down
2 changes: 1 addition & 1 deletion .release.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"beforeStartCommand": "npm run lint && npm run test",
"beforeStageCommand": "npm run changelog"
},
"commitMessage": "[[CHORE]] Bump version %s",
"commitMessage": "[[CHORE]] Bump version to %s",
"tagName": "v%s",
"tagAnnotation": "v%s",
"github": {
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# server-terminate

![TypeScript definition](https://img.shields.io/badge/TypeScript%20Definition-%E2%9C%93-blue.svg)

Allow terminating an HTTP server in an orderly fashion:
* Immediately closes keep-alive connections that are not being used by any HTTP request.
* Waits for running HTTP requests to finish before closing their connections.
Expand Down
8 changes: 4 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { Server } from 'http';

interface enableTerminateSignature {
/** Adds the `terminate` function to the provided server instance */
/** Adds the `terminate` function to the provided server instance */
(server: Server, opts?: Options): Server;
default: enableTerminateSignature;
}
Expand All @@ -18,12 +18,12 @@ interface Options {

declare module 'http' {
export interface Server {
/**
/**
* Terminates the server in an orderly fashion by
* - closing keep-alive connections that are not being used by any HTTP request.
* - waiting for running HTTP requests to finish before closing their connections.
* - closing connections with running HTTP requests after the provided timeout
* - closing connections with running HTTP requests after the provided timeout
*/
terminate(cb: (err: Error, terminatedByTimeout: boolean) => void): Server;
terminate(cb: (err: Error, terminatedByTimeout: boolean) => any): Server;
}
}
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
*/

'use strict';

module.exports = enableTerminate;
// Support for ES6 imports.
// Now you can make `import enableTerminate from 'enable-terminate'`
// and get a reference to this function
enableTerminate.default = enableTerminate;

function enableTerminate(server, opts) {
opts = opts || {};
opts.timeout = opts.timeout || 30 * 1000;
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"license": "MIT",
"author": "Jose Antonio Rodríguez <[email protected]>",
"contributors": [
"Javier Martínez Álvarez <[email protected]>"
"Javier Martínez Álvarez <[email protected]>",
"Javier Mendiara Cañardo <[email protected]>"
],
"main": "index",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions test/server-terminate.typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let server: http.Server = http.createServer(function onRequest(req: http.ServerR
server = enableTerminate(server);
server = enableTerminate(server, {});
server = enableTerminate(server, {timeout: 2000});
server.listen(8080);
server.listen(3113);

server.terminate((err, terminatedByTimeout) => {
// You get here when all connections have been closed
Expand All @@ -18,7 +18,7 @@ server.terminate((err, terminatedByTimeout) => {
server = enableTerminate2(server);
server = enableTerminate2(server, {});
server = enableTerminate2(server, {timeout: 2000});
server.listen(8080);
server.listen(3113);

server.terminate((err, terminatedByTimeout) => {
// You get here when all connections have been closed
Expand Down

0 comments on commit 129bc54

Please sign in to comment.