@verdaccio/node-api 6.0.0-6-next.24 → 6.0.0-6-next.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # @verdaccio/node-api
2
2
 
3
+ ## 6.0.0-6-next.27
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [b78f3525]
8
+ - @verdaccio/logger@6.0.0-6-next.10
9
+ - @verdaccio/server@6.0.0-6-next.26
10
+
11
+ ## 6.0.0-6-next.26
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [048ac95e]
16
+ - Updated dependencies [730b5d8c]
17
+ - @verdaccio/server@6.0.0-6-next.25
18
+ - @verdaccio/logger@6.0.0-6-next.9
19
+
20
+ ## 6.0.0-6-next.25
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies [a828271d]
25
+ - Updated dependencies [24b9be02]
26
+ - Updated dependencies [e75c0a3b]
27
+ - @verdaccio/server@6.0.0-6-next.24
28
+ - @verdaccio/core@6.0.0-6-next.4
29
+ - @verdaccio/logger@6.0.0-6-next.8
30
+ - @verdaccio/config@6.0.0-6-next.12
31
+
3
32
  ## 6.0.0-6-next.24
4
33
 
5
34
  ### Patch Changes
package/build/server.js CHANGED
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/esnext.weak-map.delete-all.js");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
@@ -41,12 +39,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
41
39
 
42
40
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
43
41
 
44
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
45
-
46
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
47
-
48
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
49
-
42
+ /* eslint-disable */
50
43
  const debug = (0, _debug.default)('verdaccio:node-api');
51
44
 
52
45
  function unlinkAddressPath(addr) {
@@ -96,12 +89,13 @@ function createServerFactory(config, addr, app) {
96
89
  cert,
97
90
  ca
98
91
  } = keyCertConfig;
99
- httpsOptions = (0, _lodash.assign)(httpsOptions, _objectSpread({
92
+ httpsOptions = (0, _lodash.assign)(httpsOptions, {
100
93
  key: _fs.default.readFileSync(key),
101
- cert: _fs.default.readFileSync(cert)
102
- }, ca && {
103
- ca: _fs.default.readFileSync(ca)
104
- }));
94
+ cert: _fs.default.readFileSync(cert),
95
+ ...(ca && {
96
+ ca: _fs.default.readFileSync(ca)
97
+ })
98
+ });
105
99
  } // TODO: enable http2 as feature
106
100
  // if (config.server.http2) <-- check if force http2
107
101
 
@@ -176,9 +170,10 @@ async function initServer(config, port, version, pkgName) {
176
170
  });
177
171
  }
178
172
 
179
- process.on('SIGINT', handleShutdownGracefully);
180
- process.on('SIGTERM', handleShutdownGracefully);
181
- process.on('SIGHUP', handleShutdownGracefully);
173
+ for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) {
174
+ // Use once() so that receiving double signals exit the app.
175
+ process.once(signal, handleShutdownGracefully);
176
+ }
182
177
  });
183
178
  }
184
179
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server.ts"],"names":["debug","unlinkAddressPath","addr","path","fs","existsSync","unlinkSync","createServerFactory","config","app","serverFactory","proto","httpsOptions","secureOptions","constants","SSL_OP_NO_SSLv2","SSL_OP_NO_SSLv3","keyCertConfig","https","pfxConfig","key","cert","pfx","Error","passphrase","readFileSync","ca","createServer","err","message","http","server","keepAliveTimeout","initServer","port","version","pkgName","Promise","resolve","reject","listen","logger","logs","flags","host","process","send","verdaccio_started","addressServer","url","format","protocol","pathname","hostname","info","on","exitCode","handleShutdownGracefully","fatal","close","exit","runServer","configurationParsed","undefined","configPathLocation","_","isObject","API_ERROR","CONFIG_BAD_FORMAT"],"mappings":";;;;;;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAGA;;AACA;;;;;;;;;;;;;;AAEA,MAAMA,KAAK,GAAG,oBAAW,oBAAX,CAAd;;AAEA,SAASC,iBAAT,CAA2BC,IAA3B,EAAiC;AAC/B,MAAIA,IAAI,CAACC,IAAL,IAAaC,YAAGC,UAAH,CAAcH,IAAI,CAACC,IAAnB,CAAjB,EAA2C;AACzCC,gBAAGE,UAAH,CAAcJ,IAAI,CAACC,IAAnB;AACD;AACF;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,mBAAT,CAA6BC,MAA7B,EAAoDN,IAApD,EAA0DO,GAA1D,EAA+D;AACpE,MAAIC,aAAJ;;AACA,MAAIR,IAAI,CAACS,KAAL,KAAe,OAAnB,EAA4B;AAC1BX,IAAAA,KAAK,CAAC,eAAD,CAAL;;AACA,QAAI;AACF,UAAIY,YAAY,GAAG;AACjB;AACAC,QAAAA,aAAa,EAAEC,mBAAUC,eAAV,GAA4BD,mBAAUE;AAFpC,OAAnB;AAKA,YAAMC,aAAa,GAAGT,MAAM,CAACU,KAA7B;AACA,YAAMC,SAAS,GAAGX,MAAM,CAACU,KAAzB,CAPE,CASF;;AACA,UAAI,EAAGD,aAAa,CAACG,GAAd,IAAqB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AGO,IAAIC,gBAAEC,QAAF,CAAW1D,MAAX,CAAJ,EAAwB;AAC7BsD,IAAAA,mBAAmB,GAAGtD,MAAtB;AACD,GAFM,MAEA;AACL,UAAM,IAAIe,KAAJ,CAAU4C,gBAAUC,iBAApB,CAAN;AACD;;AAED,qBAAMN,mBAAmB,CAACpB,IAA1B;AACA,8CAA0BoB,mBAAmB,CAACnB,KAA9C,EAZ6E,CAa7E;;AACA,QAAM,CAACzC,IAAD,IAAS,sCAAuB6D,SAAvB,EAAkCD,mBAAmB,CAACtB,MAAtD,CAAf;AACA,QAAM/B,GAAG,GAAG,MAAM,qBAAOqD,mBAAP,CAAlB;AACA,SAAOvD,mBAAmB,CAACuD,mBAAD,EAAsB5D,IAAtB,EAA4BO,GAA5B,CAA1B;AACD","sourcesContent":["/* eslint-disable */\nimport constants from 'constants';\nimport buildDebug from 'debug';\nimport fs from 'fs';\nimport http from 'http';\nimport https from 'https';\nimport _, { assign, isFunction } from 'lodash';\nimport url from 'url';\n\nimport { findConfigFile, parseConfigFile } from '@verdaccio/config';\nimport { API_ERROR } from '@verdaccio/core';\nimport { logger, setup } from '@verdaccio/logger';\nimport server from '@verdaccio/server';\nimport { ConfigRuntime, HttpsConfKeyCert, HttpsConfPfx } from '@verdaccio/types';\n\nimport { getListListenAddresses } from './cli-utils';\nimport { displayExperimentsInfoBox } from './experiments';\n\nconst debug = buildDebug('verdaccio:node-api');\n\nfunction unlinkAddressPath(addr) {\n if (addr.path && fs.existsSync(addr.path)) {\n fs.unlinkSync(addr.path);\n }\n}\n\n/**\n * Return a native HTTP/HTTPS server instance\n * @param config\n * @param addr\n * @param app\n */\nexport function createServerFactory(config: ConfigRuntime, addr, app) {\n let serverFactory;\n if (addr.proto === 'https') {\n debug('https enabled');\n try {\n let httpsOptions = {\n // disable insecure SSLv2 and SSLv3\n secureOptions: constants.SSL_OP_NO_SSLv2 | constants.SSL_OP_NO_SSLv3,\n };\n\n const keyCertConfig = config.https as HttpsConfKeyCert;\n const pfxConfig = config.https as HttpsConfPfx;\n\n // https must either have key and cert or a pfx and (optionally) a passphrase\n if (!((keyCertConfig.key && keyCertConfig.cert) || pfxConfig.pfx)) {\n // logHTTPSError(configPath);\n throw Error('bad format https configuration');\n }\n\n if (pfxConfig.pfx) {\n const { pfx, passphrase } = pfxConfig;\n httpsOptions = assign(httpsOptions, {\n pfx: fs.readFileSync(pfx),\n passphrase: passphrase || '',\n });\n } else {\n const { key, cert, ca } = keyCertConfig;\n httpsOptions = assign(httpsOptions, {\n key: fs.readFileSync(key),\n cert: fs.readFileSync(cert),\n ...(ca && {\n ca: fs.readFileSync(ca),\n }),\n });\n }\n // TODO: enable http2 as feature\n // if (config.server.http2) <-- check if force http2\n serverFactory = https.createServer(httpsOptions, app);\n } catch (err: any) {\n throw new Error(`cannot create https server: ${err.message}`);\n }\n } else {\n // http\n debug('http enabled');\n serverFactory = http.createServer(app);\n }\n\n if (\n config.server &&\n typeof config.server.keepAliveTimeout !== 'undefined' &&\n // @ts-ignore\n config.server.keepAliveTimeout !== 'null'\n ) {\n // library definition for node is not up to date (doesn't contain recent 8.0 changes)\n serverFactory.keepAliveTimeout = config.server.keepAliveTimeout * 1000;\n }\n // FIXE: I could not find the reason of this code.\n unlinkAddressPath(addr);\n\n return serverFactory;\n}\n\n/**\n * Start the server on the port defined\n * @param config\n * @param port\n * @param version\n * @param pkgName\n */\nexport async function initServer(\n config: ConfigRuntime,\n port: string | void,\n version: string,\n pkgName: string\n): Promise<void> {\n return new Promise(async (resolve, reject) => {\n // FIXME: get only the first match, the multiple address will be removed\n const [addr] = getListListenAddresses(port, config.listen);\n const logger = setup((config as ConfigRuntime).logs);\n displayExperimentsInfoBox(config.flags);\n const app = await server(config);\n const serverFactory = createServerFactory(config, addr, app);\n serverFactory\n .listen(addr.port || addr.path, addr.host, (): void => {\n // send a message for test\n if (isFunction(process.send)) {\n process.send({\n verdaccio_started: true,\n });\n }\n const addressServer = `${\n addr.path\n ? url.format({\n protocol: 'unix',\n pathname: addr.path,\n })\n : url.format({\n protocol: addr.proto,\n hostname: addr.host,\n port: addr.port,\n pathname: '/',\n })\n }`;\n logger.info(`http address ${addressServer}`);\n logger.info(`version: ${version}`);\n resolve();\n })\n .on('error', function (err): void {\n reject(err);\n process.exitCode = 1;\n });\n\n function handleShutdownGracefully() {\n logger.fatal('received shutdown signal - closing server gracefully...');\n serverFactory.close(() => {\n logger.info('server closed.');\n process.exit(0);\n });\n }\n\n process.on('SIGINT', handleShutdownGracefully);\n process.on('SIGTERM', handleShutdownGracefully);\n process.on('SIGHUP', handleShutdownGracefully);\n });\n}\n\n/**\n * Exposes a server factory to be instantiated programmatically.\n *\n const app = await runServer(); // default configuration\n const app = await runServer('./config/config.yaml');\n const app = await runServer({ configuration });\n app.listen(4000, (event) => {\n // do something\n });\n * @param config\n */\nexport async function runServer(config?: string | ConfigRuntime): Promise<any> {\n let configurationParsed: ConfigRuntime;\n if (config === undefined || typeof config === 'string') {\n const configPathLocation = findConfigFile(config);\n configurationParsed = parseConfigFile(configPathLocation);\n } else if (_.isObject(config)) {\n configurationParsed = config;\n } else {\n throw new Error(API_ERROR.CONFIG_BAD_FORMAT);\n }\n\n setup(configurationParsed.logs);\n displayExperimentsInfoBox(configurationParsed.flags);\n // FIXME: get only the first match, the multiple address will be removed\n const [addr] = getListListenAddresses(undefined, configurationParsed.listen);\n const app = await server(configurationParsed);\n return createServerFactory(configurationParsed, addr, app);\n}\n"],"file":"server.js"}
1
+ {"version":3,"sources":["../src/server.ts"],"names":["debug","unlinkAddressPath","addr","path","fs","existsSync","unlinkSync","createServerFactory","config","app","serverFactory","proto","httpsOptions","secureOptions","constants","SSL_OP_NO_SSLv2","SSL_OP_NO_SSLv3","keyCertConfig","https","pfxConfig","key","cert","pfx","Error","passphrase","readFileSync","ca","createServer","err","message","http","server","keepAliveTimeout","initServer","port","version","pkgName","Promise","resolve","reject","listen","logger","logs","flags","host","process","send","verdaccio_started","addressServer","url","format","protocol","pathname","hostname","info","on","exitCode","handleShutdownGracefully","fatal","close","exit","signal","once","runServer","configurationParsed","undefined","configPathLocation","_","isObject","API_ERROR","CONFIG_BAD_FORMAT"],"mappings":";;;;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAGA;;AACA;;;;;;;;AAhBA;AAkBA,MAAMA,KAAK,GAAG,oBAAW,oBAAX,CAAd;;AAEA,SAASC,iBAAT,CAA2BC,IAA3B,EAAiC;AAC/B,MAAIA,IAAI,CAACC,IAAL,IAAaC,YAAGC,UAAH,CAAcH,IAAI,CAACC,IAAnB,CAAjB,EAA2C;AACzCC,gBAAGE,UAAH,CAAcJ,IAAI,CAACC,IAAnB;AACD;AACF;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,mBAAT,CAA6BC,MAA7B,EAAoDN,IAApD,EAA0DO,GAA1D,EAA+D;AACpE,MAAIC,aAAJ;;AACA,MAAIR,IAAI,CAACS,KAAL,KAAe,OAAnB,EAA4B;AAC1BX,IAAAA,KAAK,CAAC,eAAD,CAAL;;AACA,QAAI;AACF,UAAIY,YAAY,GAAG;AACjB;AACAC,QAAAA,aAAa,EAAEC,mBAAUC,eAAV,GAA4BD,mBAAUE;AAFpC,OAAnB;AAKA,YAAMC,aAAa,GAAGT,MAAM,CAACU,KAA7B;AACA,YAAMC,SAAS,GAAGX,MAAM,CAACU,KAAzB,CAPE,CASF;;AACA,UAAI,EAAGD,aAAa,CAACG,GAAd,IAAqBH,aAAa,CAACI,IAApC,IAA6CF,SAAS,CAACG,GAAzD,CAAJ,EAAmE;AACjE;AACA,cAAMC,KAAK,CAAC,gCAAD,CAAX;AACD;;AAED,UAAIJ,SAAS,CAACG,GAAd,EAAmB;AACjB,cAAM;AAAEA,UAAAA,GAAF;AAAOE,UAAAA;AAAP,YAAsBL,SAA5B;AACAP,QAAAA,YAAY,GAAG,oBAAOA,YAAP,EAAqB;AAClCU,UAAAA,GAAG,EAAElB,YAAGqB,YAAH,CAA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B+D,SAAvB,EAAkCD,mBAAmB,CAACxB,MAAtD,CAAf;AACA,QAAM/B,GAAG,GAAG,MAAM,qBAAOuD,mBAAP,CAAlB;AACA,SAAOzD,mBAAmB,CAACyD,mBAAD,EAAsB9D,IAAtB,EAA4BO,GAA5B,CAA1B;AACD","sourcesContent":["/* eslint-disable */\nimport constants from 'constants';\nimport buildDebug from 'debug';\nimport fs from 'fs';\nimport http from 'http';\nimport https from 'https';\nimport _, { assign, isFunction } from 'lodash';\nimport url from 'url';\n\nimport { findConfigFile, parseConfigFile } from '@verdaccio/config';\nimport { API_ERROR } from '@verdaccio/core';\nimport { logger, setup } from '@verdaccio/logger';\nimport server from '@verdaccio/server';\nimport { ConfigRuntime, HttpsConfKeyCert, HttpsConfPfx } from '@verdaccio/types';\n\nimport { getListListenAddresses } from './cli-utils';\nimport { displayExperimentsInfoBox } from './experiments';\n\nconst debug = buildDebug('verdaccio:node-api');\n\nfunction unlinkAddressPath(addr) {\n if (addr.path && fs.existsSync(addr.path)) {\n fs.unlinkSync(addr.path);\n }\n}\n\n/**\n * Return a native HTTP/HTTPS server instance\n * @param config\n * @param addr\n * @param app\n */\nexport function createServerFactory(config: ConfigRuntime, addr, app) {\n let serverFactory;\n if (addr.proto === 'https') {\n debug('https enabled');\n try {\n let httpsOptions = {\n // disable insecure SSLv2 and SSLv3\n secureOptions: constants.SSL_OP_NO_SSLv2 | constants.SSL_OP_NO_SSLv3,\n };\n\n const keyCertConfig = config.https as HttpsConfKeyCert;\n const pfxConfig = config.https as HttpsConfPfx;\n\n // https must either have key and cert or a pfx and (optionally) a passphrase\n if (!((keyCertConfig.key && keyCertConfig.cert) || pfxConfig.pfx)) {\n // logHTTPSError(configPath);\n throw Error('bad format https configuration');\n }\n\n if (pfxConfig.pfx) {\n const { pfx, passphrase } = pfxConfig;\n httpsOptions = assign(httpsOptions, {\n pfx: fs.readFileSync(pfx),\n passphrase: passphrase || '',\n });\n } else {\n const { key, cert, ca } = keyCertConfig;\n httpsOptions = assign(httpsOptions, {\n key: fs.readFileSync(key),\n cert: fs.readFileSync(cert),\n ...(ca && {\n ca: fs.readFileSync(ca),\n }),\n });\n }\n // TODO: enable http2 as feature\n // if (config.server.http2) <-- check if force http2\n serverFactory = https.createServer(httpsOptions, app);\n } catch (err: any) {\n throw new Error(`cannot create https server: ${err.message}`);\n }\n } else {\n // http\n debug('http enabled');\n serverFactory = http.createServer(app);\n }\n\n if (\n config.server &&\n typeof config.server.keepAliveTimeout !== 'undefined' &&\n // @ts-ignore\n config.server.keepAliveTimeout !== 'null'\n ) {\n // library definition for node is not up to date (doesn't contain recent 8.0 changes)\n serverFactory.keepAliveTimeout = config.server.keepAliveTimeout * 1000;\n }\n // FIXE: I could not find the reason of this code.\n unlinkAddressPath(addr);\n\n return serverFactory;\n}\n\n/**\n * Start the server on the port defined\n * @param config\n * @param port\n * @param version\n * @param pkgName\n */\nexport async function initServer(\n config: ConfigRuntime,\n port: string | void,\n version: string,\n pkgName: string\n): Promise<void> {\n return new Promise(async (resolve, reject) => {\n // FIXME: get only the first match, the multiple address will be removed\n const [addr] = getListListenAddresses(port, config.listen);\n const logger = setup((config as ConfigRuntime).logs);\n displayExperimentsInfoBox(config.flags);\n const app = await server(config);\n const serverFactory = createServerFactory(config, addr, app);\n serverFactory\n .listen(addr.port || addr.path, addr.host, (): void => {\n // send a message for test\n if (isFunction(process.send)) {\n process.send({\n verdaccio_started: true,\n });\n }\n const addressServer = `${\n addr.path\n ? url.format({\n protocol: 'unix',\n pathname: addr.path,\n })\n : url.format({\n protocol: addr.proto,\n hostname: addr.host,\n port: addr.port,\n pathname: '/',\n })\n }`;\n logger.info(`http address ${addressServer}`);\n logger.info(`version: ${version}`);\n resolve();\n })\n .on('error', function (err): void {\n reject(err);\n process.exitCode = 1;\n });\n\n function handleShutdownGracefully() {\n logger.fatal('received shutdown signal - closing server gracefully...');\n serverFactory.close(() => {\n logger.info('server closed.');\n process.exit(0);\n });\n }\n\n for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) {\n // Use once() so that receiving double signals exit the app.\n process.once(signal, handleShutdownGracefully);\n }\n });\n}\n\n/**\n * Exposes a server factory to be instantiated programmatically.\n *\n const app = await runServer(); // default configuration\n const app = await runServer('./config/config.yaml');\n const app = await runServer({ configuration });\n app.listen(4000, (event) => {\n // do something\n });\n * @param config\n */\nexport async function runServer(config?: string | ConfigRuntime): Promise<any> {\n let configurationParsed: ConfigRuntime;\n if (config === undefined || typeof config === 'string') {\n const configPathLocation = findConfigFile(config);\n configurationParsed = parseConfigFile(configPathLocation);\n } else if (_.isObject(config)) {\n configurationParsed = config;\n } else {\n throw new Error(API_ERROR.CONFIG_BAD_FORMAT);\n }\n\n setup(configurationParsed.logs);\n displayExperimentsInfoBox(configurationParsed.flags);\n // FIXME: get only the first match, the multiple address will be removed\n const [addr] = getListListenAddresses(undefined, configurationParsed.listen);\n const app = await server(configurationParsed);\n return createServerFactory(configurationParsed, addr, app);\n}\n"],"file":"server.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/node-api",
3
- "version": "6.0.0-6-next.24",
3
+ "version": "6.0.0-6-next.27",
4
4
  "description": "node API",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -30,21 +30,21 @@
30
30
  },
31
31
  "license": "MIT",
32
32
  "dependencies": {
33
- "@verdaccio/core": "6.0.0-6-next.3",
34
- "@verdaccio/config": "6.0.0-6-next.11",
35
- "@verdaccio/logger": "6.0.0-6-next.7",
36
- "@verdaccio/server": "6.0.0-6-next.23",
37
- "core-js": "3.17.2",
38
- "debug": "4.3.2",
33
+ "@verdaccio/core": "6.0.0-6-next.4",
34
+ "@verdaccio/config": "6.0.0-6-next.12",
35
+ "@verdaccio/logger": "6.0.0-6-next.10",
36
+ "@verdaccio/server": "6.0.0-6-next.26",
37
+ "core-js": "3.20.3",
38
+ "debug": "4.3.3",
39
39
  "lodash": "4.17.21"
40
40
  },
41
41
  "devDependencies": {
42
- "@types/node": "16.11.6",
43
- "@verdaccio/mock": "6.0.0-6-next.12",
44
- "@verdaccio/types": "11.0.0-6-next.9",
42
+ "@types/node": "16.11.21",
43
+ "@verdaccio/mock": "6.0.0-6-next.13",
44
+ "@verdaccio/types": "11.0.0-6-next.10",
45
45
  "jest-mock-process": "1.4.1",
46
- "selfsigned": "1.10.11",
47
- "supertest": "6.1.6"
46
+ "selfsigned": "1.10.14",
47
+ "supertest": "6.2.2"
48
48
  },
49
49
  "publishConfig": {
50
50
  "access": "public"
package/src/server.ts CHANGED
@@ -150,9 +150,10 @@ export async function initServer(
150
150
  });
151
151
  }
152
152
 
153
- process.on('SIGINT', handleShutdownGracefully);
154
- process.on('SIGTERM', handleShutdownGracefully);
155
- process.on('SIGHUP', handleShutdownGracefully);
153
+ for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) {
154
+ // Use once() so that receiving double signals exit the app.
155
+ process.once(signal, handleShutdownGracefully);
156
+ }
156
157
  });
157
158
  }
158
159