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 4.0.8 to 4.0.9

2

lib/index.js

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

(()=>{var e={155:(e,t,s)=>{"use strict";s.d(t,{default:()=>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},260:(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(155),i=s(665);const a=(e,t)=>async(s,n,o)=>{const{timeout:a,closePromises:u}=r.default,d=o&&o.message?o:new Error(s);var c;t.status.set(i.Z.SHUTTING_DOWN,d),await(c=a,new Promise((e=>setTimeout(e,c)))),await Promise.all(u.map((e=>e()))),await e.stop(),t.status.set(i.Z.SHUTDOWN,d),process.exit(128+n)},u=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:d,readinessEndpoint:c}=r.default,l=(e,t)=>{const{healthCheck:s,kubernetes:n}=r.default,o=u(),i=u();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.default;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!==d&&e.url!==c||"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)}}},665:(e,t,s)=>{"use strict";s.d(t,{Z:()=>o});var n=function(e){return e.STARTING="STARTING",e.READY="READY",e.SHUTTING_DOWN="SHUTTING_DOWN",e.SHUTDOWN="SHUTDOWN",e}(n||{});const o=n},80:()=>{}},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(155),t=s(260),o=s(665),r=s(80),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={244:(e,t,s)=>{"use strict";s.d(t,{A:()=>i,l:()=>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},103:(e,t,s)=>{"use strict";s.d(t,{A:()=>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(244),i=s(400);const a=(e,t)=>async(s,n,o)=>{const{timeout:a,closePromises:c}=r.A,d=o&&o.message?o:new Error(s);var u;t.status.set(i.A.SHUTTING_DOWN,d),await(u=a,new Promise((e=>setTimeout(e,u)))),await Promise.all(c.map((e=>e()))),await e.stop(),t.status.set(i.A.SHUTDOWN,d),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:d,readinessEndpoint:u}=r.A,l=(e,t)=>{const{healthCheck:s,kubernetes:n}=r.A,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.A;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!==d&&e.url!==u||"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.A.STARTING;return{set:function(s,n){return t=s,e.emit(s,n),this},get:()=>t,setReady:function(){this.set(i.A.READY)},isReady:()=>t===i.A.READY,isShuttingDown:()=>t===i.A.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)}}},400:(e,t,s)=>{"use strict";s.d(t,{A:()=>o});var n=function(e){return e.STARTING="STARTING",e.READY="READY",e.SHUTTING_DOWN="SHUTTING_DOWN",e.SHUTDOWN="SHUTDOWN",e}(n||{});const o=n},97:()=>{}},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(244),t=s(103),o=s(400),r=s(97),i={};for(const e in r)"default"!==e&&(i[e]=()=>r[e]);s.d(n,i);const a=Object.assign(((s,n)=>{(0,e.l)(n);const o=(0,t.A)(s).init();return{isReady:()=>o.status.isReady(),setReady:()=>o.status.setReady(),on:o.on}}),o.A)})(),module.exports=n})();const __export__=module.exports;module.exports=__export__.default,Object.assign(module.exports,__export__);
{
"name": "@gquittet/graceful-server",
"version": "4.0.8",
"version": "4.0.9",
"description": "Tiny (~5k), dependency-free Node.JS library to make your API more graceful",

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

"devDependencies": {
"@babel/cli": "^7.22.9",
"@babel/core": "^7.22.9",
"@babel/cli": "^7.23.9",
"@babel/core": "^7.24.0",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
"@babel/preset-env": "^7.22.4",
"@babel/preset-typescript": "^7.21.5",
"@types/express": "^4.17.17",
"@types/jest": "^29.5.2",
"@types/node": "^18.15.2",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"@babel/preset-env": "^7.24.0",
"@babel/preset-typescript": "^7.23.3",
"@types/express": "^4.17.21",
"@types/jest": "^29.5.12",
"@types/node": "^20.11.29",
"@typescript-eslint/eslint-plugin": "^7.3.0",
"@typescript-eslint/parser": "^7.3.0",
"add-module-exports-webpack-plugin": "^2.0.0",
"babel-loader": "^9.1.2",
"babel-loader": "^9.1.3",
"babel-plugin-module-resolver": "^5.0.0",
"eslint": "^8.42.0",
"eslint-config-prettier": "^8.8.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard": "^17.1.0",
"eslint-import-resolver-babel-module": "^5.3.2",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-module-resolver": "^1.5.0",
"eslint-plugin-n": "^16.0.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-promise": "^6.1.1",
"esm": "^3.2.25",
"fork-ts-checker-webpack-plugin": "^8.0.0",
"husky": "^8.0.3",
"jest": "^29.6.1",
"lint-staged": "^13.2.3",
"fork-ts-checker-webpack-plugin": "^9.0.2",
"husky": "^9.0.11",
"jest": "^29.7.0",
"lint-staged": "^15.2.2",
"pinst": "^3.0.0",
"prettier": "^2.8.8",
"prettier": "^3.2.5",
"prettier-package-json": "^2.8.0",
"rimraf": "^5.0.1",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"rimraf": "^5.0.5",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"ttypescript": "^1.5.15",
"typescript": "^4.9.5",
"typescript-transform-paths": "^3.4.6",
"webpack": "^5.86.0",
"typescript-transform-paths": "^3.4.7",
"webpack": "^5.90.3",
"webpack-cli": "^5.1.4"

@@ -61,0 +61,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