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 1.2.1 to 1.2.2

2

lib/index.js

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

module.exports=function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t){e.exports=require("events")},function(e,t,n){"use strict";n.r(t);const o={closePromises:[],timeout:1e3,healthCheck:!0,livenessEndpoint:"/live",readinessEndpoint:"/ready"};let r=!0;var s=o;var i=[{type:"SIGHUP",code:1},{type:"SIGBREAK",code:1},{type:"SIGINT",code:2},{type:"SIGTERM",code:15},{type:"uncaughtException",code:2}];var a,u=e=>{for(const t of i)process.on(t.type,async n=>{await e.shutdown(t.type,t.code,n)});return e};!function(e){e.STARTING="STARTING",e.READY="READY",e.SHUTTING_DOWN="SHUTTING_DOWN",e.SHUTDOWN="SHUTDOWN"}(a||(a={}));var c=a;var l=e=>new Promise(t=>setTimeout(t,e));var d=(e,t)=>async(n,o,r)=>{const{timeout:i,closePromises:a}=s,u=r&&r.message?r:new Error(n);t.status.set(c.SHUTTING_DOWN,u),await l(i),await Promise.all(a.map(e=>e())),await e.stop(),t.status.set(c.SHUTDOWN,u),process.exit(128+o)},p=n(0);const{livenessEndpoint:f,readinessEndpoint:y}=s;var v={apply:e=>{e.disable("x-powered-by"),e.get(f,()=>{}),e.get(y,()=>{})}};var m=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;var T=(()=>{let e,t=!0;return{validate:function(t){return e=t,m(e)},patch:()=>{e&&t&&(v.apply(e),t=!1)}}})();var h=e=>(t,n)=>{const{livenessEndpoint:o,readinessEndpoint:r}=s;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===r&&"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};var S=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)}};var E=(e,t)=>{const{healthCheck:n}=s,o=S(),r=S();let i=!1;e.on("connection",o.onConnection),e.on("secureConnection",r.onConnection),e.listeners("request").forEach(e=>{T.validate(e)&&T.patch()});const a=e.listeners("request");e.removeAllListeners("request"),n&&e.on("request",h(t)),a.forEach(n=>e.on("request",(e,o)=>{t.isReady()?n(e,o):e.socket.destroy()}));return Object.assign(e,{stop:async()=>{if(e.listening&&!i)return i=!0,e.removeAllListeners("request"),e.on("request",(e,t)=>{if(!t.headersSent)return t.setHeader("connection","close")}),await Promise.all([o.closeAll(),r.closeAll()]),new Promise((t,n)=>{e.close(e=>{e?n(e):t()})})}})};var _=e=>{let t=c.STARTING;return{set:function(n,o){return t=n,e.emit(n,o),this},get:()=>t,setReady:function(){this.set(c.READY)},isReady:()=>t===c.READY}};var b=e=>{const t=new p.EventEmitter,n=_(t),o=E(e,n);return{status:n,init:function(){return u(this)},shutdown:function(e,t,n){return d(o,this)(e,t,n)},on:(e,n)=>t.on(e,n)}};const O=Object.assign((e,t)=>{var n;n=t,r&&(Object.freeze(Object.assign(o,n)),r=!1);const s=b(e).init();return{isReady:()=>s.status.isReady(),setReady:()=>s.status.setReady(),on:s.on}},c);t.default=O}]);const __export__=module.exports;module.exports=__export__.default,Object.assign(module.exports,__export__);
module.exports=function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t){e.exports=require("events")},function(e,t,n){"use strict";n.r(t);const o={closePromises:[],timeout:1e3,healthCheck:!0,livenessEndpoint:"/live",readinessEndpoint:"/ready"};let r=!0;var s=o;var i=[{type:"SIGHUP",code:1},{type:"SIGBREAK",code:1},{type:"SIGINT",code:2},{type:"SIGTERM",code:15},{type:"uncaughtException",code:2}];var a,u=e=>{for(const t of i)process.on(t.type,async n=>{await e.shutdown(t.type,t.code,n)});return e};!function(e){e.STARTING="STARTING",e.READY="READY",e.SHUTTING_DOWN="SHUTTING_DOWN",e.SHUTDOWN="SHUTDOWN"}(a||(a={}));var c=a;var l=e=>new Promise(t=>setTimeout(t,e));var d=(e,t)=>async(n,o,r)=>{const{timeout:i,closePromises:a}=s,u=r&&r.message?r:new Error(n);t.status.set(c.SHUTTING_DOWN,u),await l(i),await Promise.all(a.map(e=>e())),await e.stop(),t.status.set(c.SHUTDOWN,u),process.exit(128+o)},p=n(0);const{livenessEndpoint:f,readinessEndpoint:y}=s;var v={apply:e=>{e.disable("x-powered-by"),e.get(f,()=>{}),e.get(y,()=>{})}};var m=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;var T=(()=>{let e=!0;return{validate:e=>m(e),patch:t=>{e&&(v.apply(t),e=!1)}}})();var h=e=>(t,n)=>{const{livenessEndpoint:o,readinessEndpoint:r}=s;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===r&&"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};var S=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)}};var E=(e,t)=>{const{healthCheck:n}=s,o=S(),r=S();let i=!1;e.on("connection",o.onConnection),e.on("secureConnection",r.onConnection);const a=e.listeners("request");e.removeAllListeners("request"),n&&(a.forEach(e=>{T.validate(e)&&T.patch(e)}),e.on("request",h(t))),a.forEach(n=>e.on("request",(e,o)=>{t.isReady()?n(e,o):e.socket.destroy()}));return Object.assign(e,{stop:async()=>{if(e.listening&&!i)return i=!0,e.removeAllListeners("request"),e.on("request",(e,t)=>{if(!t.headersSent)return t.setHeader("connection","close")}),await Promise.all([o.closeAll(),r.closeAll()]),new Promise((t,n)=>{e.close(e=>{e?n(e):t()})})}})};var _=e=>{let t=c.STARTING;return{set:function(n,o){return t=n,e.emit(n,o),this},get:()=>t,setReady:function(){this.set(c.READY)},isReady:()=>t===c.READY}};var b=e=>{const t=new p.EventEmitter,n=_(t),o=E(e,n);return{status:n,init:function(){return u(this)},shutdown:function(e,t,n){return d(o,this)(e,t,n)},on:(e,n)=>t.on(e,n)}};const O=Object.assign((e,t)=>{var n;n=t,r&&(Object.freeze(Object.assign(o,n)),r=!1);const s=b(e).init();return{isReady:()=>s.status.isReady(),setReady:()=>s.status.setReady(),on:s.on}},c);t.default=O}]);const __export__=module.exports;module.exports=__export__.default,Object.assign(module.exports,__export__);
import { Express } from 'express';
declare const expressPatcher: {
validate: (app: Express) => boolean;
patch: () => void;
patch: (app: Express) => void;
};
export default expressPatcher;

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

"license": "MIT",
"version": "1.2.1",
"version": "1.2.2",
"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