@verdaccio/node-api 6.0.0-6-next.36 → 6.0.0-6-next.48

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,86 @@
1
1
  # @verdaccio/node-api
2
2
 
3
+ ## 6.0.0-6-next.48
4
+
5
+ ### Major Changes
6
+
7
+ - 9fc2e796: feat(plugins): improve plugin loader
8
+
9
+ ### Changes
10
+
11
+ - Add scope plugin support to 6.x https://github.com/verdaccio/verdaccio/pull/3227
12
+ - Avoid config collisions https://github.com/verdaccio/verdaccio/issues/928
13
+ - https://github.com/verdaccio/verdaccio/issues/1394
14
+ - `config.plugins` plugin path validations
15
+ - Updated algorithm for plugin loader.
16
+ - improved documentation (included dev)
17
+
18
+ ## Features
19
+
20
+ - Add scope plugin support to 6.x https://github.com/verdaccio/verdaccio/pull/3227
21
+ - Custom prefix:
22
+
23
+ ```
24
+ // config.yaml
25
+ server:
26
+ pluginPrefix: mycompany
27
+ middleware:
28
+ audit:
29
+ foo: 1
30
+ ```
31
+
32
+ This configuration will look up for `mycompany-audit` instead `Verdaccio-audit`.
33
+
34
+ ## Breaking Changes
35
+
36
+ ### sinopia plugins
37
+
38
+ - `sinopia` fallback support is removed, but can be restored using `pluginPrefix`
39
+
40
+ ### plugin filter
41
+
42
+ - method rename `filter_metadata`->`filterMetadata`
43
+
44
+ ### Plugin constructor does not merge configs anymore https://github.com/verdaccio/verdaccio/issues/928
45
+
46
+ The plugin receives as first argument `config`, which represents the config of the plugin. Example:
47
+
48
+ ```
49
+ // config.yaml
50
+ auth:
51
+ plugin:
52
+ foo: 1
53
+ bar: 2
54
+
55
+ export class Plugin<T> {
56
+ public constructor(config: T, options: PluginOptions) {
57
+ console.log(config);
58
+ // {foo:1, bar: 2}
59
+ }
60
+ }
61
+ ```
62
+
63
+ ### Patch Changes
64
+
65
+ - Updated dependencies [43f32687]
66
+ - Updated dependencies [9fc2e796]
67
+ - Updated dependencies [62c24b63]
68
+ - @verdaccio/core@6.0.0-6-next.48
69
+ - @verdaccio/server-fastify@6.0.0-6-next.29
70
+ - @verdaccio/config@6.0.0-6-next.48
71
+ - @verdaccio/server@6.0.0-6-next.37
72
+ - @verdaccio/logger@6.0.0-6-next.16
73
+
74
+ ## 6.0.0-6-next.47
75
+
76
+ ### Patch Changes
77
+
78
+ - @verdaccio/core@6.0.0-6-next.47
79
+ - @verdaccio/config@6.0.0-6-next.47
80
+ - @verdaccio/logger@6.0.0-6-next.15
81
+ - @verdaccio/server@6.0.0-6-next.36
82
+ - @verdaccio/server-fastify@6.0.0-6-next.28
83
+
3
84
  ## 6.0.0-6-next.36
4
85
 
5
86
  ### Patch Changes
package/build/server.js CHANGED
@@ -180,7 +180,7 @@ async function initServer(config, port, version, pkgName) {
180
180
  });
181
181
 
182
182
  function handleShutdownGracefully() {
183
- logger.warn('received shutdown signal - closing server gracefully...');
183
+ logger.info('received shutdown signal - closing server gracefully...');
184
184
  serverFactory.close(() => {
185
185
  logger.info('server closed.');
186
186
  process.exit(0);
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","names":["debug","buildDebug","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","assign","readFileSync","ca","createServer","err","message","http","server","keepAliveTimeout","initServer","port","version","pkgName","Promise","resolve","reject","getListListenAddresses","listen","logger","setup","log","displayExperimentsInfoBox","flags","process","env","VERDACCIO_SERVER","fastifyServer","host","isFunction","send","verdaccio_started","addressServer","url","format","protocol","pathname","hostname","info","on","exitCode","handleShutdownGracefully","warn","close","exit","signal","once","runServer","configurationParsed","undefined","configPathLocation","findConfigFile","parseConfigFile","_","isObject","API_ERROR","CONFIG_BAD_FORMAT"],"sources":["../src/server.ts"],"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 { setup } from '@verdaccio/logger';\nimport server from '@verdaccio/server';\nimport fastifyServer from '@verdaccio/server-fastify';\nimport { ConfigYaml, 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: ConfigYaml, 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: ConfigYaml,\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?.log as any);\n displayExperimentsInfoBox(config.flags);\n\n let app;\n if (process.env.VERDACCIO_SERVER === 'fastify') {\n app = await fastifyServer(config);\n app.listen({ port: addr.port, host: addr.host }, (err) => {\n if (err) {\n reject(err);\n } else {\n resolve();\n }\n });\n } else {\n 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 function handleShutdownGracefully() {\n logger.warn('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/**\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 | ConfigYaml): Promise<any> {\n let configurationParsed: ConfigYaml;\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.log as any);\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"],"mappings":";;;;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;;;;;;;AAjBA;AAmBA,MAAMA,KAAK,GAAG,IAAAC,cAAA,EAAW,oBAAX,CAAd;;AAEA,SAASC,iBAAT,CAA2BC,IAA3B,EAAiC;EAC/B,IAAIA,IAAI,CAACC,IAAL,IAAaC,WAAA,CAAGC,UAAH,CAAcH,IAAI,CAACC,IAAnB,CAAjB,EAA2C;IACzCC,WAAA,CAAGE,UAAH,CAAcJ,IAAI,CAACC,IAAnB;EACD;AACF;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,mBAAT,CAA6BC,MAA7B,EAAiDN,IAAjD,EAAuDO,GAAvD,EAA4D;EACjE,IAAIC,aAAJ;;EACA,IAAIR,IAAI,CAACS,KAAL,KAAe,OAAnB,EAA4B;IAC1BZ,KAAK,CAAC,eAAD,CAAL;;IACA,IAAI;MACF,IAAIa,YAAY,GAAG;QACjB;QACAC,aAAa,EAAEC,kBAAA,CAAUC,eAAV,GAA4BD,kBAAA,CAAUE;MAFpC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,MAAX,IAAqB,CAAC,QAAD,EAAW,SAAX,EAAsB,QAAtB,CAArB,EAAsD;QACpD;QACArB,OAAO,CAACsB,IAAR,CAAaD,MAAb,EAAqBJ,wBAArB;MACD;IACF;EACF,CA7DM,CAAP;AA8DD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,eAAeM,SAAf,CAAyB/D,MAAzB,EAAqE;EAC1E,IAAIgE,mBAAJ;;EACA,IAAIhE,MAAM,KAAKiE,SAAX,IAAwB,OAAOjE,MAAP,KAAkB,QAA9C,EAAwD;IACtD,MAAMkE,kBAAkB,GAAG,IAAAC,sBAAA,EAAenE,MAAf,CAA3B;IACAgE,mBAAmB,GAAG,IAAAI,uBAAA,EAAgBF,kBAAhB,CAAtB;EACD,CAHD,MAGO,IAAIG,eAAA,CAAEC,QAAF,CAAWtE,MAAX,CAAJ,EAAwB;IAC7BgE,mBAAmB,GAAGhE,MAAtB;EACD,CAFM,MAEA;IACL,MAAM,IAAIe,KAAJ,CAAUwD,eAAA,CAAUC,iBAApB,CAAN;EACD;;EAED,IAAApC,aAAA,EAAM4B,mBAAmB,CAAC3B,GAA1B;EACA,IAAAC,sCAAA,EAA0B0B,mBAAmB,CAACzB,KAA9C,EAZ0E,CAa1E;;EACA,MAAM,CAAC7C,IAAD,IAAS,IAAAuC,gCAAA,EAAuBgC,SAAvB,EAAkCD,mBAAmB,CAAC9B,MAAtD,CAAf;EACA,MAAMjC,GAAG,GAAG,MAAM,IAAAuB,eAAA,EAAOwC,mBAAP,CAAlB;EACA,OAAOjE,mBAAmB,CAACiE,mBAAD,EAAsBtE,IAAtB,EAA4BO,GAA5B,CAA1B;AACD"}
1
+ {"version":3,"file":"server.js","names":["debug","buildDebug","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","assign","readFileSync","ca","createServer","err","message","http","server","keepAliveTimeout","initServer","port","version","pkgName","Promise","resolve","reject","getListListenAddresses","listen","logger","setup","log","displayExperimentsInfoBox","flags","process","env","VERDACCIO_SERVER","fastifyServer","host","expressServer","isFunction","send","verdaccio_started","addressServer","url","format","protocol","pathname","hostname","info","on","exitCode","handleShutdownGracefully","close","exit","signal","once","runServer","configurationParsed","undefined","configPathLocation","findConfigFile","parseConfigFile","_","isObject","API_ERROR","CONFIG_BAD_FORMAT"],"sources":["../src/server.ts"],"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 { setup } from '@verdaccio/logger';\nimport expressServer from '@verdaccio/server';\nimport fastifyServer from '@verdaccio/server-fastify';\nimport { ConfigYaml, 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: ConfigYaml, 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: ConfigYaml,\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?.log as any);\n displayExperimentsInfoBox(config.flags);\n\n let app;\n if (process.env.VERDACCIO_SERVER === 'fastify') {\n app = await fastifyServer(config);\n app.listen({ port: addr.port, host: addr.host }, (err) => {\n if (err) {\n reject(err);\n } else {\n resolve();\n }\n });\n } else {\n app = await expressServer(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 function handleShutdownGracefully() {\n logger.info('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/**\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 | ConfigYaml): Promise<any> {\n let configurationParsed: ConfigYaml;\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.log as any);\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 expressServer(configurationParsed);\n return createServerFactory(configurationParsed, addr, app);\n}\n"],"mappings":";;;;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;;;;;;;AAjBA;AAmBA,MAAMA,KAAK,GAAG,IAAAC,cAAA,EAAW,oBAAX,CAAd;;AAEA,SAASC,iBAAT,CAA2BC,IAA3B,EAAiC;EAC/B,IAAIA,IAAI,CAACC,IAAL,IAAaC,WAAA,CAAGC,UAAH,CAAcH,IAAI,CAACC,IAAnB,CAAjB,EAA2C;IAC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AAvB,EAAkCD,mBAAmB,CAAC9B,MAAtD,CAAf;EACA,MAAMjC,GAAG,GAAG,MAAM,IAAA4C,eAAA,EAAcmB,mBAAd,CAAlB;EACA,OAAOjE,mBAAmB,CAACiE,mBAAD,EAAsBtE,IAAtB,EAA4BO,GAA5B,CAA1B;AACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/node-api",
3
- "version": "6.0.0-6-next.36",
3
+ "version": "6.0.0-6-next.48",
4
4
  "description": "node API",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -30,18 +30,18 @@
30
30
  },
31
31
  "license": "MIT",
32
32
  "dependencies": {
33
- "@verdaccio/core": "6.0.0-6-next.8",
34
- "@verdaccio/config": "6.0.0-6-next.17",
35
- "@verdaccio/logger": "6.0.0-6-next.14",
36
- "@verdaccio/server": "6.0.0-6-next.35",
37
- "@verdaccio/server-fastify": "6.0.0-6-next.27",
38
- "core-js": "3.25.0",
33
+ "@verdaccio/core": "6.0.0-6-next.48",
34
+ "@verdaccio/config": "6.0.0-6-next.48",
35
+ "@verdaccio/logger": "6.0.0-6-next.16",
36
+ "@verdaccio/server": "6.0.0-6-next.37",
37
+ "@verdaccio/server-fastify": "6.0.0-6-next.29",
38
+ "core-js": "3.25.2",
39
39
  "debug": "4.3.4",
40
40
  "lodash": "4.17.21"
41
41
  },
42
42
  "devDependencies": {
43
- "@types/node": "16.11.56",
44
- "@verdaccio/types": "11.0.0-6-next.16",
43
+ "@types/node": "16.11.60",
44
+ "@verdaccio/types": "11.0.0-6-next.17",
45
45
  "jest-mock-process": "1.5.1",
46
46
  "selfsigned": "1.10.14",
47
47
  "supertest": "6.2.4"
package/src/server.ts CHANGED
@@ -10,7 +10,7 @@ import url from 'url';
10
10
  import { findConfigFile, parseConfigFile } from '@verdaccio/config';
11
11
  import { API_ERROR } from '@verdaccio/core';
12
12
  import { setup } from '@verdaccio/logger';
13
- import server from '@verdaccio/server';
13
+ import expressServer from '@verdaccio/server';
14
14
  import fastifyServer from '@verdaccio/server-fastify';
15
15
  import { ConfigYaml, HttpsConfKeyCert, HttpsConfPfx } from '@verdaccio/types';
16
16
 
@@ -123,7 +123,7 @@ export async function initServer(
123
123
  }
124
124
  });
125
125
  } else {
126
- app = await server(config);
126
+ app = await expressServer(config);
127
127
  const serverFactory = createServerFactory(config, addr, app);
128
128
  serverFactory
129
129
  .listen(addr.port || addr.path, addr.host, (): void => {
@@ -155,7 +155,7 @@ export async function initServer(
155
155
  process.exitCode = 1;
156
156
  });
157
157
  function handleShutdownGracefully() {
158
- logger.warn('received shutdown signal - closing server gracefully...');
158
+ logger.info('received shutdown signal - closing server gracefully...');
159
159
  serverFactory.close(() => {
160
160
  logger.info('server closed.');
161
161
  process.exit(0);
@@ -196,6 +196,6 @@ export async function runServer(config?: string | ConfigYaml): Promise<any> {
196
196
  displayExperimentsInfoBox(configurationParsed.flags);
197
197
  // FIXME: get only the first match, the multiple address will be removed
198
198
  const [addr] = getListListenAddresses(undefined, configurationParsed.listen);
199
- const app = await server(configurationParsed);
199
+ const app = await expressServer(configurationParsed);
200
200
  return createServerFactory(configurationParsed, addr, app);
201
201
  }