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.0.0 to 2.0.1

2

lib/index.js

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

module.exports=(()=>{"use strict";var e={11:(e,t,n)=>{n.r(t),n.d(t,{default:()=>E});const s={closePromises:[],timeout:1e3,healthCheck:!0,livenessEndpoint:"/live",readinessEndpoint:"/ready"};let o=!0;const r=e=>(o&&(Object.freeze(Object.assign(s,e)),o=!1),s),i=s,a=[{type:"SIGHUP",code:1},{type:"SIGBREAK",code:1},{type:"SIGINT",code:2},{type:"SIGTERM",code:15},{type:"uncaughtException",code:2}];var c;!function(e){e.STARTING="STARTING",e.READY="READY",e.SHUTTING_DOWN="SHUTTING_DOWN",e.SHUTDOWN="SHUTDOWN"}(c||(c={}));const u=c,d=(e,t)=>async(n,s,o)=>{const{timeout:r,closePromises:a}=i,c=o&&o.message?o:new Error(n);var d;t.status.set(u.SHUTTING_DOWN,c),await(d=r,new Promise((e=>setTimeout(e,d)))),await Promise.all(a.map((e=>e()))),await e.stop(),t.status.set(u.SHUTDOWN,c),process.exit(128+s)},p=require("events"),{livenessEndpoint:l,readinessEndpoint:y}=i,f=e=>{e.get(l,(()=>{})),e.get(y,(()=>{})),e._router.stack.unshift(e._router.stack.pop()),e._router.stack.unshift(e._router.stack.pop())},m=(()=>{let e=!0;return{validate:e=>{return(t=e)&&t._router&&Array.isArray(t._router.stack)&&t.request&&t.response&&t===t.request.app&&t===t.response.app&&"function"==typeof t.init&&"function"==typeof t.listen&&"function"==typeof t.use;var t},patch:t=>{e&&(f(t),e=!1)}}})(),h=e=>{const t=e||new Set,n=e=>{e.destroy(),t.delete(e)};return{onConnection:e=>{t.add(e),e.once("close",(()=>t.delete(e)))},closeAll:async()=>t.forEach(n)}},T=(e,t)=>{const{healthCheck:n}=i,s=h(),o=h();let r=!1;e.on("connection",s.onConnection),e.on("secureConnection",o.onConnection);const a=e.listeners("request");return e.removeAllListeners("request"),n&&(a.forEach((e=>{m.validate(e)&&m.patch(e)})),e.on("request",(e=>(t,n)=>{const{livenessEndpoint:s,readinessEndpoint:o}=i;if(!n.headersSent)return t.url===s&&"GET"===t.method?(n.statusCode=200,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify({uptime:0|process.uptime()}))):t.url===o&&"GET"===t.method?e.isReady()?(n.statusCode=200,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify({status:"ready"}))):(n.statusCode=503,n.end()):void 0})(t))),a.forEach((n=>e.on("request",((e,s)=>{t.isReady()?n(e,s):e.socket.destroy()})))),Object.assign(e,{stop:async()=>{if(e.listening&&!r)return r=!0,e.removeAllListeners("request"),e.on("request",((e,t)=>{if(!t.headersSent)return t.setHeader("connection","close")})),await Promise.all([s.closeAll(),o.closeAll()]),new Promise(((t,n)=>{e.close((e=>{e?n(e):t()}))}))}})},S=e=>{let t=u.STARTING;return{set:function(n,s){return t=n,e.emit(n,s),this},get:()=>t,setReady:function(){this.set(u.READY)},isReady:()=>t===u.READY}},_=e=>{const t=new p.EventEmitter,n=S(t),s=T(e,n);return{status:n,init:function(){return(e=>{for(const t of a)process.on(t.type,(async n=>{await e.shutdown(t.type,t.code,n)}));return e})(this)},shutdown:function(e,t,n){return d(s,this)(e,t,n)},on:(e,n)=>t.on(e,n)}},E=Object.assign(((e,t)=>{r(t);const n=_(e).init();return{isReady:()=>n.status.isReady(),setReady:()=>n.status.setReady(),on:n.on}}),u)}},t={};function n(s){if(t[s])return t[s].exports;var o=t[s]={exports:{}};return e[s](o,o.exports,n),o.exports}return n.d=(e,t)=>{for(var s in t)n.o(t,s)&&!n.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(11)})();const __export__=module.exports;module.exports=__export__.default,Object.assign(module.exports,__export__);
module.exports=(()=>{"use strict";var e={11:(e,t,n)=>{n.r(t),n.d(t,{default:()=>v});const o={closePromises:[],timeout:1e3,healthCheck:!0,livenessEndpoint:"/live",readinessEndpoint:"/ready"};let s=!0;const r=e=>(s&&(Object.freeze(Object.assign(o,e)),s=!1),o),i=o,a=[{type:"SIGHUP",code:1},{type:"SIGBREAK",code:1},{type:"SIGINT",code:2},{type:"SIGTERM",code:15},{type:"uncaughtException",code:2}];var c;!function(e){e.STARTING="STARTING",e.READY="READY",e.SHUTTING_DOWN="SHUTTING_DOWN",e.SHUTDOWN="SHUTDOWN"}(c||(c={}));const u=c,d=(e,t)=>async(n,o,s)=>{const{timeout:r,closePromises:a}=i,c=s&&s.message?s:new Error(n);var d;t.status.set(u.SHUTTING_DOWN,c),await(d=r,new Promise((e=>setTimeout(e,d)))),await Promise.all(a.map((e=>e()))),await e.stop(),t.status.set(u.SHUTDOWN,c),process.exit(128+o)},l=require("events"),{livenessEndpoint:p,readinessEndpoint:y}=i,f=e=>{const t=e.handle;e.handle=function(n,o,s){n.url!==p&&n.url!==y&&t.call(e,n,o,s)}},m=e=>(e=>e&&e.request&&e.response&&e===e.request.app&&e===e.response.app&&"function"==typeof e.init&&"function"==typeof e.listen&&"function"==typeof e.use)(e)&&((e=>e._router&&Array.isArray(e._router.stack))(e)||(e=>e.router&&Array.isArray(e.router.stack))(e)),h=(()=>{let e=!0;return{validate:e=>m(e),patch:t=>{e&&(f(t),e=!1)}}})(),T=e=>{const t=e||new Set,n=e=>{e.destroy(),t.delete(e)};return{onConnection:e=>{t.add(e),e.once("close",(()=>t.delete(e)))},closeAll:async()=>t.forEach(n)}},S=(e,t)=>{const{healthCheck:n}=i,o=T(),s=T();let r=!1;e.on("connection",o.onConnection),e.on("secureConnection",s.onConnection);const a=e.listeners("request");return e.removeAllListeners("request"),n&&(a.forEach((e=>{h.validate(e)&&h.patch(e)})),e.on("request",(e=>(t,n)=>{const{livenessEndpoint:o,readinessEndpoint:s}=i;if(!n.headersSent)return t.url===o&&"GET"===t.method?(n.statusCode=200,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify({uptime:0|process.uptime()}))):t.url===s&&"GET"===t.method?e.isReady()?(n.statusCode=200,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify({status:"ready"}))):(n.statusCode=503,n.end()):void 0})(t))),a.forEach((n=>e.on("request",((e,o)=>{t.isReady()?n(e,o):e.socket.destroy()})))),Object.assign(e,{stop:async()=>{if(e.listening&&!r)return r=!0,e.removeAllListeners("request"),e.on("request",((e,t)=>{if(!t.headersSent)return t.setHeader("connection","close")})),await Promise.all([o.closeAll(),s.closeAll()]),new Promise(((t,n)=>{e.close((e=>{e?n(e):t()}))}))}})},E=e=>{let t=u.STARTING;return{set:function(n,o){return t=n,e.emit(n,o),this},get:()=>t,setReady:function(){this.set(u.READY)},isReady:()=>t===u.READY}},_=e=>{const t=new l.EventEmitter,n=E(t),o=S(e,n);return{status:n,init:function(){return(e=>{for(const t of a)process.on(t.type,(async n=>{await e.shutdown(t.type,t.code,n)}));return e})(this)},shutdown:function(e,t,n){return d(o,this)(e,t,n)},on:(e,n)=>t.on(e,n)}},v=Object.assign(((e,t)=>{r(t);const n=_(e).init();return{isReady:()=>n.status.isReady(),setReady:()=>n.status.setReady(),on:n.on}}),u)}},t={};function n(o){if(t[o])return t[o].exports;var s=t[o]={exports:{}};return e[o](s,s.exports,n),s.exports}return n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(11)})();const __export__=module.exports;module.exports=__export__.default,Object.assign(module.exports,__export__);

@@ -1,5 +0,4 @@

import { Express } from 'express';
declare const patch: {
apply: (app: Express) => void;
apply: (app: any) => void;
};
export default patch;

@@ -30,3 +30,3 @@ {

"license": "MIT",
"version": "2.0.0",
"version": "2.0.1",
"main": "./lib/index.js",

@@ -33,0 +33,0 @@ "types": "./lib/types/index.d.ts",

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