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 3.0.0 to 3.0.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},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){if(t.url===n&&"GET"===t.method)return s.statusCode=200,s.setHeader("Content-Type","application/json"),void s.end(JSON.stringify({uptime:0|process.uptime()}));if(t.url===o&&"GET"===t.method){if(e.isReady())return s.statusCode=200,s.setHeader("Content-Type","application/json"),void s.end(JSON.stringify({status:"ready"}));s.statusCode=503,s.end()}}})(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)=>{t.headersSent||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__);
(()=>{var e={636:(e,t,s)=>{"use strict";s.d(t,{Z:()=>i,u:()=>r});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){if(t.url===n&&"GET"===t.method)return s.statusCode=200,s.setHeader("Content-Type","application/json"),void s.end(JSON.stringify({uptime:0|process.uptime()}));if(t.url===o&&"GET"===t.method){if(e.isReady())return s.statusCode=200,s.setHeader("Content-Type","application/json"),void s.end(JSON.stringify({status:"ready"}));s.statusCode=503,s.end()}}})(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)=>{t.headersSent||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 IGracefulServerOptions from "../interface/gracefulServerOptions";
import IOptions from "../interface/options";
declare const options: IOptions;
export declare const makeOptions: (newOptions?: IGracefulServerOptions | undefined) => IOptions;
export declare const makeOptions: (newOptions?: IGracefulServerOptions) => IOptions;
export default options;

@@ -1,4 +0,3 @@

/// <reference types="node" />
import * as net from 'net';
declare const SocketsPool: (sockets?: Set<net.Socket> | undefined) => {
declare const SocketsPool: (sockets?: Set<net.Socket>) => {
onConnection: (socket: net.Socket) => void;

@@ -5,0 +4,0 @@ closeAll: () => Promise<void>;

@@ -5,4 +5,4 @@ import State from "./core/state";

import Server from './interface/server';
declare const GracefulServer: ((server: Server, options?: IGracefulServerOptions | undefined) => IGracefulServer) & typeof State;
declare const GracefulServer: ((server: Server, options?: IGracefulServerOptions) => IGracefulServer) & typeof State;
export * from "./interface/gracefulServer";
export default GracefulServer;
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import * as http from 'http';

@@ -3,0 +6,0 @@ import * as http2 from 'http2';

/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import * as http from 'http';

@@ -3,0 +6,0 @@ import * as http2 from 'http2';

import ICore from "../interface/core";
import ImprovedServer from "../interface/improvedServer";
declare const shutdown: (server: ImprovedServer, parent: ICore) => (type: string, value: number, body?: Error | undefined) => Promise<never>;
declare const shutdown: (server: ImprovedServer, parent: ICore) => (type: string, value: number, body?: Error) => Promise<never>;
export default shutdown;
{
"name": "@gquittet/graceful-server",
"version": "3.0.0",
"version": "3.0.2",
"description": "Tiny (~5k), dependency-free Node.JS library to make your API more graceful",

@@ -40,39 +40,39 @@ "license": "MIT",

"devDependencies": {
"@babel/cli": "7.17.0",
"@babel/core": "7.17.0",
"@babel/plugin-proposal-class-properties": "7.16.7",
"@babel/plugin-proposal-object-rest-spread": "7.16.7",
"@babel/preset-env": "7.16.11",
"@babel/preset-typescript": "7.16.7",
"@babel/cli": "7.17.10",
"@babel/core": "7.18.2",
"@babel/plugin-proposal-class-properties": "7.17.12",
"@babel/plugin-proposal-object-rest-spread": "7.18.0",
"@babel/preset-env": "7.18.2",
"@babel/preset-typescript": "7.17.12",
"@types/express": "4.17.13",
"@types/jest": "27.4.0",
"@types/jest": "27.5.1",
"@types/node": "16.11.22",
"@typescript-eslint/eslint-plugin": "5.10.2",
"@typescript-eslint/parser": "5.10.2",
"@typescript-eslint/eslint-plugin": "5.27.0",
"@typescript-eslint/parser": "5.27.0",
"add-module-exports-webpack-plugin": "2.0.0",
"babel-loader": "8.2.3",
"babel-loader": "8.2.5",
"babel-plugin-module-resolver": "4.1.0",
"eslint": "7.32.0",
"eslint-config-prettier": "7.2.0",
"eslint-config-standard": "16.0.3",
"eslint": "8.16.0",
"eslint-config-prettier": "8.5.0",
"eslint-config-standard": "17.0.0",
"eslint-import-resolver-babel-module": "5.3.1",
"eslint-plugin-import": "2.25.4",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-module-resolver": "1.4.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "5.2.0",
"eslint-plugin-n": "15.2.0",
"eslint-plugin-promise": "6.0.0",
"esm": "3.2.25",
"fork-ts-checker-webpack-plugin": "7.0.0",
"husky": "7.0.4",
"jest": "27.5.0",
"lint-staged": "12.3.3",
"pinst": "2.1.6",
"prettier": "2.5.1",
"prettier-package-json": "2.6.0",
"fork-ts-checker-webpack-plugin": "7.2.11",
"husky": "8.0.1",
"jest": "28.1.0",
"lint-staged": "12.5.0",
"pinst": "3.0.0",
"prettier": "2.6.2",
"prettier-package-json": "2.6.3",
"rimraf": "3.0.2",
"ts-jest": "27.1.3",
"ts-node": "10.4.0",
"ts-jest": "28.0.3",
"ts-node": "10.8.0",
"ttypescript": "1.5.13",
"typescript": "4.5.5",
"typescript": "4.7.2",
"typescript-transform-paths": "3.3.1",
"webpack": "5.68.0",
"webpack": "5.72.1",
"webpack-cli": "4.9.2"

@@ -79,0 +79,0 @@ },

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