Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gquittet/graceful-server

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gquittet/graceful-server - npm Package Compare versions

Comparing version 2.5.1 to 2.5.2

2

lib/index.js

@@ -1,1 +0,1 @@

(()=>{var e={636:(e,t,s)=>{"use strict";s.d(t,{u:()=>r,Z:()=>i});const n={closePromises:[],timeout:1e3,healthCheck:!0,kubernetes:!1,livenessEndpoint:"/live",readinessEndpoint:"/ready"};let o=!0;const r=e=>(o&&(Object.freeze(Object.assign(n,e)),o=!1),n),i=n},751:(e,t,s)=>{"use strict";s.d(t,{Z:()=>y});const n=require("events"),o=[{type:"SIGHUP",code:1},{type:"SIGBREAK",code:1},{type:"SIGINT",code:2},{type:"SIGTERM",code:15},{type:"uncaughtException",code:2}];var r=s(636),i=s(825);const a=(e,t)=>async(s,n,o)=>{const{timeout:a,closePromises:c}=r.Z,u=o&&o.message?o:new Error(s);var d;t.status.set(i.Z.SHUTTING_DOWN,u),await(d=a,new Promise((e=>setTimeout(e,d)))),await Promise.all(c.map((e=>e()))),await e.stop(),t.status.set(i.Z.SHUTDOWN,u),process.exit(128+n)},c=e=>{const t=e||new Set,s=e=>{e.destroy(),t.delete(e)};return{onConnection:e=>{t.add(e),e.once("close",(()=>t.delete(e)))},closeAll:async()=>t.forEach(s)}},{livenessEndpoint:u,readinessEndpoint:d}=r.Z,l=(e,t)=>{const{healthCheck:s,kubernetes:n}=r.Z,o=c(),i=c();let a=!1;e.on("connection",o.onConnection),e.on("secureConnection",i.onConnection);const l=e.listeners("request");return e.removeAllListeners("request"),s?(e.on("request",(e=>(t,s)=>{const{livenessEndpoint:n,readinessEndpoint:o}=r.Z;if(!s.headersSent)return t.url===n&&"GET"===t.method?(s.statusCode=200,s.setHeader("Content-Type","application/json"),s.end(JSON.stringify({uptime:0|process.uptime()}))):t.url===o&&"GET"===t.method?e.isReady()?(s.statusCode=200,s.setHeader("Content-Type","application/json"),s.end(JSON.stringify({status:"ready"}))):(s.statusCode=503,s.end()):void 0})(t)),l.forEach((s=>e.on("request",((e,o)=>(n?t.isReady()||t.isShuttingDown():t.isReady())?e.url!==u&&e.url!==d||"GET"!==e.method?s(e,o):void 0:e.socket.destroy()))))):l.forEach((s=>e.on("request",((e,n)=>{if(t.isReady())return s(e,n);e.socket.destroy()})))),Object.assign(e,{stop:async()=>{if(e.listening&&!a)return a=!0,e.removeAllListeners("request"),e.on("request",((e,t)=>{if(!t.headersSent)return t.setHeader("connection","close")})),await Promise.all([o.closeAll(),i.closeAll()]),new Promise(((t,s)=>{e.close((e=>{e?s(e):t()}))}))}})},p=e=>{let t=i.Z.STARTING;return{set:function(s,n){return t=s,e.emit(s,n),this},get:()=>t,setReady:function(){this.set(i.Z.READY)},isReady:()=>t===i.Z.READY,isShuttingDown:()=>t===i.Z.SHUTTING_DOWN}},y=e=>{const t=new n.EventEmitter,s=p(t),r=l(e,s);return{status:s,init:function(){return(e=>{for(const t of o)process.on(t.type,(async s=>{await e.shutdown(t.type,t.code,s)}));return e})(this)},shutdown:function(e,t,s){return a(r,this)(e,t,s)},on:(e,s)=>t.on(e,s)}}},825:(e,t,s)=>{"use strict";var n;s.d(t,{Z:()=>o}),function(e){e.STARTING="STARTING",e.READY="READY",e.SHUTTING_DOWN="SHUTTING_DOWN",e.SHUTDOWN="SHUTDOWN"}(n||(n={}));const o=n},878:()=>{}},t={};function s(n){var o=t[n];if(void 0!==o)return o.exports;var r=t[n]={exports:{}};return e[n](r,r.exports,s),r.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{"use strict";s.r(n),s.d(n,{default:()=>a});var e=s(636),t=s(751),o=s(825),r=s(878),i={};for(const e in r)"default"!==e&&(i[e]=()=>r[e]);s.d(n,i);const a=Object.assign(((s,n)=>{(0,e.u)(n);const o=(0,t.Z)(s).init();return{isReady:()=>o.status.isReady(),setReady:()=>o.status.setReady(),on:o.on}}),o.Z)})(),module.exports=n})();const __export__=module.exports;module.exports=__export__.default,Object.assign(module.exports,__export__);
(()=>{var e={636:(e,t,s)=>{"use strict";s.d(t,{u:()=>r,Z:()=>i});const n={closePromises:[],timeout:1e3,healthCheck:!0,kubernetes:!1,livenessEndpoint:"/live",readinessEndpoint:"/ready"};let o=!0;const r=e=>(o&&(Object.freeze(Object.assign(n,e)),o=!1),n),i=n},116:(e,t,s)=>{"use strict";s.d(t,{Z:()=>y});const n=require("events"),o=[{type:"SIGHUP",code:1},{type:"SIGBREAK",code:1},{type:"SIGINT",code:2},{type:"SIGTERM",code:15},{type:"uncaughtException",code:2}];var r=s(636),i=s(825);const a=(e,t)=>async(s,n,o)=>{const{timeout:a,closePromises:c}=r.Z,u=o&&o.message?o:new Error(s);var d;t.status.set(i.Z.SHUTTING_DOWN,u),await(d=a,new Promise((e=>setTimeout(e,d)))),await Promise.all(c.map((e=>e()))),await e.stop(),t.status.set(i.Z.SHUTDOWN,u),process.exit(128+n)},c=e=>{const t=e||new Set,s=e=>{e.destroy(),t.delete(e)};return{onConnection:e=>{t.add(e),e.once("close",(()=>t.delete(e)))},closeAll:async()=>t.forEach(s)}},{livenessEndpoint:u,readinessEndpoint:d}=r.Z,l=(e,t)=>{const{healthCheck:s,kubernetes:n}=r.Z,o=c(),i=c();let a=!1;e.on("connection",o.onConnection),e.on("secureConnection",i.onConnection);const l=e.listeners("request");return e.removeAllListeners("request"),s?(e.on("request",(e=>(t,s)=>{const{livenessEndpoint:n,readinessEndpoint:o}=r.Z;if(!s.headersSent)return t.url===n&&"GET"===t.method?(s.statusCode=200,s.setHeader("Content-Type","application/json"),s.end(JSON.stringify({uptime:0|process.uptime()}))):t.url===o&&"GET"===t.method?e.isReady()?(s.statusCode=200,s.setHeader("Content-Type","application/json"),s.end(JSON.stringify({status:"ready"}))):(s.statusCode=503,s.end()):void 0})(t)),l.forEach((s=>e.on("request",((e,o)=>(n?t.isReady()||t.isShuttingDown():t.isReady())?e.url!==u&&e.url!==d||"GET"!==e.method?s(e,o):void 0:e.socket.destroy()))))):l.forEach((s=>e.on("request",((e,n)=>{if(t.isReady())return s(e,n);e.socket.destroy()})))),Object.assign(e,{stop:async()=>{if(e.listening&&!a)return a=!0,e.removeAllListeners("request"),e.on("request",((e,t)=>{if(!t.headersSent)return t.setHeader("connection","close")})),await Promise.all([o.closeAll(),i.closeAll()]),new Promise(((t,s)=>{e.close((e=>{e?s(e):t()}))}))}})},p=e=>{let t=i.Z.STARTING;return{set:function(s,n){return t=s,e.emit(s,n),this},get:()=>t,setReady:function(){this.set(i.Z.READY)},isReady:()=>t===i.Z.READY,isShuttingDown:()=>t===i.Z.SHUTTING_DOWN}},y=e=>{const t=new n.EventEmitter,s=p(t),r=l(e,s);return{status:s,init:function(){return(e=>{for(const t of o)process.on(t.type,(async s=>{await e.shutdown(t.type,t.code,s)}));return e})(this)},shutdown:function(e,t,s){return a(r,this)(e,t,s)},on:(e,s)=>t.on(e,s)}}},825:(e,t,s)=>{"use strict";var n;s.d(t,{Z:()=>o}),function(e){e.STARTING="STARTING",e.READY="READY",e.SHUTTING_DOWN="SHUTTING_DOWN",e.SHUTDOWN="SHUTDOWN"}(n||(n={}));const o=n},878:()=>{}},t={};function s(n){var o=t[n];if(void 0!==o)return o.exports;var r=t[n]={exports:{}};return e[n](r,r.exports,s),r.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{"use strict";s.r(n),s.d(n,{default:()=>a});var e=s(636),t=s(116),o=s(825),r=s(878),i={};for(const e in r)"default"!==e&&(i[e]=()=>r[e]);s.d(n,i);const a=Object.assign(((s,n)=>{(0,e.u)(n);const o=(0,t.Z)(s).init();return{isReady:()=>o.status.isReady(),setReady:()=>o.status.setReady(),on:o.on}}),o.Z)})(),module.exports=n})();const __export__=module.exports;module.exports=__export__.default,Object.assign(module.exports,__export__);
import ImprovedServer from "../interface/improvedServer";
import IStatus from "../interface/status";
import Server from "../interface/server";
import Server from '../interface/server';
declare const improvedServer: (server: Server, serverStatus: IStatus) => ImprovedServer;
export default improvedServer;
import ICore from "../interface/core";
import Server from "../interface/server";
import Server from '../interface/server';
declare const core: (server: Server) => ICore;
export default core;
import State from "./core/state";
import IGracefulServer from "./interface/gracefulServer";
import IGracefulServerOptions from "./interface/gracefulServerOptions";
import Server from "./interface/server";
import Server from './interface/server';
declare const GracefulServer: ((server: Server, options?: IGracefulServerOptions | undefined) => IGracefulServer) & typeof State;
export * from "./interface/gracefulServer";
export default GracefulServer;
/// <reference types="node" />
import { EventEmitter } from 'events';
import IStatus from "./status";
import IStatus from './status';
export default interface ICore {

@@ -5,0 +5,0 @@ status: IStatus;

{
"name": "@gquittet/graceful-server",
"version": "2.5.2",
"description": "Tiny (~5k), dependency-free Node.JS library to make your API more graceful",

@@ -12,6 +13,5 @@ "license": "MIT",

"bugs": {
"url": "https://github.com/gquittet/graceful-server/issues",
"email": "guillaume.quittet@gmail.com"
"email": "guillaume.quittet@gmail.com",
"url": "https://github.com/gquittet/graceful-server/issues"
},
"version": "2.5.1",
"main": "./lib/index.js",

@@ -38,40 +38,40 @@ "scripts": {

"devDependencies": {
"@babel/cli": "7.13.16",
"@babel/core": "7.14.0",
"@babel/plugin-proposal-class-properties": "7.13.0",
"@babel/plugin-proposal-object-rest-spread": "7.13.8",
"@babel/preset-env": "7.14.1",
"@babel/preset-typescript": "7.13.0",
"@types/express": "4.17.11",
"@types/jest": "26.0.23",
"@types/node": "14.14.43",
"@typescript-eslint/eslint-plugin": "4.22.1",
"@typescript-eslint/parser": "4.22.1",
"@babel/cli": "7.16.0",
"@babel/core": "7.16.0",
"@babel/plugin-proposal-class-properties": "7.16.0",
"@babel/plugin-proposal-object-rest-spread": "7.16.0",
"@babel/preset-env": "7.16.0",
"@babel/preset-typescript": "7.16.0",
"@types/express": "4.17.13",
"@types/jest": "27.0.2",
"@types/node": "14.17.33",
"@typescript-eslint/eslint-plugin": "5.3.1",
"@typescript-eslint/parser": "5.3.1",
"add-module-exports-webpack-plugin": "2.0.0",
"babel-loader": "8.2.2",
"babel-loader": "8.2.3",
"babel-plugin-module-resolver": "4.1.0",
"eslint": "7.25.0",
"eslint": "8.2.0",
"eslint-config-prettier": "8.3.0",
"eslint-config-standard": "16.0.2",
"eslint-config-standard": "16.0.3",
"eslint-import-resolver-babel-module": "5.3.1",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-module-resolver": "1.2.0",
"eslint-plugin-import": "2.25.2",
"eslint-plugin-module-resolver": "1.4.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "5.1.0",
"eslint-plugin-promise": "5.1.1",
"esm": "3.2.25",
"fork-ts-checker-webpack-plugin": "6.2.6",
"husky": "6.0.0",
"jest": "26.6.3",
"lint-staged": "10.5.4",
"fork-ts-checker-webpack-plugin": "6.4.0",
"husky": "7.0.4",
"jest": "27.3.1",
"lint-staged": "11.2.6",
"pinst": "2.1.6",
"prettier": "2.2.1",
"prettier-package-json": "2.1.3",
"prettier": "2.4.1",
"prettier-package-json": "2.6.0",
"rimraf": "3.0.2",
"ts-jest": "26.5.5",
"ts-node": "9.1.1",
"ts-jest": "27.0.7",
"ts-node": "10.4.0",
"ttypescript": "1.5.12",
"typescript": "4.2.4",
"typescript-transform-paths": "2.2.3",
"webpack": "5.36.2",
"webpack-cli": "4.6.0"
"typescript": "4.4.4",
"typescript-transform-paths": "3.3.1",
"webpack": "5.62.1",
"webpack-cli": "4.9.1"
},

@@ -90,3 +90,2 @@ "keywords": [

"eslintConfig": {
"root": true,
"env": {

@@ -96,3 +95,2 @@ "jest": true,

},
"parser": "@typescript-eslint/parser",
"extends": [

@@ -104,2 +102,7 @@ "eslint:recommended",

],
"ignorePatterns": [
"/node_modules/",
"/lib/"
],
"parser": "@typescript-eslint/parser",
"plugins": [

@@ -109,14 +112,15 @@ "module-resolver",

],
"root": true,
"rules": {
"space-before-function-paren": "off",
"no-unused-vars": "off",
"module-resolver/use-alias": 2,
"@typescript-eslint/no-unused-vars": [
"error",
{
"vars": "all",
"args": "after-used",
"ignoreRestSiblings": false
"ignoreRestSiblings": false,
"vars": "all"
}
]
],
"module-resolver/use-alias": 2,
"no-unused-vars": "off",
"space-before-function-paren": "off"
},

@@ -127,30 +131,26 @@ "settings": {

}
},
"ignorePatterns": [
"/node_modules/",
"/lib/"
]
}
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"globals": {
"ts-jest": {
"compiler": "ttypescript",
"tsconfig": "tsconfig.json",
"diagnostics": true
"diagnostics": true,
"tsconfig": "tsconfig.json"
}
},
"testRegex": "/tests/.*\\.test\\.ts",
"moduleNameMapper": {
"~/(.*)": "<rootDir>/src/$1"
}
},
"preset": "ts-jest",
"testEnvironment": "node",
"testRegex": "/tests/.*\\.test\\.ts"
},
"lint-staged": {
"*.ts": "eslint --cache --fix",
"*.{ts,md}": "prettier --write",
"package.json": [
"prettier-package-json --write",
"git add"
],
"*.ts": "eslint --cache --fix",
"*.{ts,md}": "prettier --write"
]
},

@@ -157,0 +157,0 @@ "prettier": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc