@verdaccio/node-api 6.0.0-6-next.47 → 6.0.0-6-next.49
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 +81 -0
- package/README.md +0 -67
- package/build/server.d.ts +2 -0
- package/build/server.js +3 -1
- package/build/server.js.map +1 -1
- package/package.json +10 -10
- package/src/server.ts +6 -4
- package/test/run-server.spec.ts +1 -1
- package/tsconfig.build.json +1 -2
- package/tsconfig.json +1 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,86 @@
|
|
|
1
1
|
# @verdaccio/node-api
|
|
2
2
|
|
|
3
|
+
## 6.0.0-6-next.49
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @verdaccio/server@6.0.0-6-next.38
|
|
8
|
+
- @verdaccio/server-fastify@6.0.0-6-next.30
|
|
9
|
+
- @verdaccio/core@6.0.0-6-next.49
|
|
10
|
+
- @verdaccio/config@6.0.0-6-next.49
|
|
11
|
+
- @verdaccio/logger@6.0.0-6-next.17
|
|
12
|
+
|
|
13
|
+
## 6.0.0-6-next.48
|
|
14
|
+
|
|
15
|
+
### Major Changes
|
|
16
|
+
|
|
17
|
+
- 9fc2e796: feat(plugins): improve plugin loader
|
|
18
|
+
|
|
19
|
+
### Changes
|
|
20
|
+
|
|
21
|
+
- Add scope plugin support to 6.x https://github.com/verdaccio/verdaccio/pull/3227
|
|
22
|
+
- Avoid config collisions https://github.com/verdaccio/verdaccio/issues/928
|
|
23
|
+
- https://github.com/verdaccio/verdaccio/issues/1394
|
|
24
|
+
- `config.plugins` plugin path validations
|
|
25
|
+
- Updated algorithm for plugin loader.
|
|
26
|
+
- improved documentation (included dev)
|
|
27
|
+
|
|
28
|
+
## Features
|
|
29
|
+
|
|
30
|
+
- Add scope plugin support to 6.x https://github.com/verdaccio/verdaccio/pull/3227
|
|
31
|
+
- Custom prefix:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
// config.yaml
|
|
35
|
+
server:
|
|
36
|
+
pluginPrefix: mycompany
|
|
37
|
+
middleware:
|
|
38
|
+
audit:
|
|
39
|
+
foo: 1
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This configuration will look up for `mycompany-audit` instead `Verdaccio-audit`.
|
|
43
|
+
|
|
44
|
+
## Breaking Changes
|
|
45
|
+
|
|
46
|
+
### sinopia plugins
|
|
47
|
+
|
|
48
|
+
- `sinopia` fallback support is removed, but can be restored using `pluginPrefix`
|
|
49
|
+
|
|
50
|
+
### plugin filter
|
|
51
|
+
|
|
52
|
+
- method rename `filter_metadata`->`filterMetadata`
|
|
53
|
+
|
|
54
|
+
### Plugin constructor does not merge configs anymore https://github.com/verdaccio/verdaccio/issues/928
|
|
55
|
+
|
|
56
|
+
The plugin receives as first argument `config`, which represents the config of the plugin. Example:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
// config.yaml
|
|
60
|
+
auth:
|
|
61
|
+
plugin:
|
|
62
|
+
foo: 1
|
|
63
|
+
bar: 2
|
|
64
|
+
|
|
65
|
+
export class Plugin<T> {
|
|
66
|
+
public constructor(config: T, options: PluginOptions) {
|
|
67
|
+
console.log(config);
|
|
68
|
+
// {foo:1, bar: 2}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Patch Changes
|
|
74
|
+
|
|
75
|
+
- Updated dependencies [43f32687]
|
|
76
|
+
- Updated dependencies [9fc2e796]
|
|
77
|
+
- Updated dependencies [62c24b63]
|
|
78
|
+
- @verdaccio/core@6.0.0-6-next.48
|
|
79
|
+
- @verdaccio/server-fastify@6.0.0-6-next.29
|
|
80
|
+
- @verdaccio/config@6.0.0-6-next.48
|
|
81
|
+
- @verdaccio/server@6.0.0-6-next.37
|
|
82
|
+
- @verdaccio/logger@6.0.0-6-next.16
|
|
83
|
+
|
|
3
84
|
## 6.0.0-6-next.47
|
|
4
85
|
|
|
5
86
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,72 +1,5 @@
|
|
|
1
1
|
# @verdaccio/node-api
|
|
2
2
|
|
|
3
|
-
[](https://opencollective.com/verdaccio)
|
|
4
|
-
[](https://stackshare.io/verdaccio)
|
|
5
|
-
[](https://github.com/verdaccio/verdaccio/blob/master/LICENSE)
|
|
6
|
-
[](https://crowdin.com/project/verdaccio)
|
|
7
|
-
[](https://www.tickgit.com/browse?repo=github.com/verdaccio/verdaccio)
|
|
8
|
-
|
|
9
|
-
[](https://twitter.com/verdaccio_npm)
|
|
10
|
-
[](https://github.com/verdaccio/verdaccio/stargazers)
|
|
11
|
-
|
|
12
|
-
## Donations
|
|
13
|
-
|
|
14
|
-
Verdaccio is run by **volunteers**; nobody is working full-time on it. If you find this project to be useful and would like to support its development, consider making a donation - **your logo might end up in this readme.** 😉
|
|
15
|
-
|
|
16
|
-
**[Donate](https://opencollective.com/verdaccio)** 💵👍🏻 starting from _\$1/month_ or just one single contribution.
|
|
17
|
-
|
|
18
|
-
## Report a vulnerability
|
|
19
|
-
|
|
20
|
-
If you want to report a security vulnerability, please follow the steps which we have defined for you in our [security policy](https://github.com/verdaccio/verdaccio/security/policy).
|
|
21
|
-
|
|
22
|
-
## Open Collective Sponsors
|
|
23
|
-
|
|
24
|
-
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/verdaccio#sponsor)]
|
|
25
|
-
|
|
26
|
-
[](https://opencollective.com/verdaccio/sponsor/0/website)
|
|
27
|
-
[](https://opencollective.com/verdaccio/sponsor/1/website)
|
|
28
|
-
[](https://opencollective.com/verdaccio/sponsor/2/website)
|
|
29
|
-
[](https://opencollective.com/verdaccio/sponsor/3/website)
|
|
30
|
-
[](https://opencollective.com/verdaccio/sponsor/4/website)
|
|
31
|
-
[](https://opencollective.com/verdaccio/sponsor/5/website)
|
|
32
|
-
[](https://opencollective.com/verdaccio/sponsor/6/website)
|
|
33
|
-
[](https://opencollective.com/verdaccio/sponsor/7/website)
|
|
34
|
-
[](https://opencollective.com/verdaccio/sponsor/8/website)
|
|
35
|
-
[](https://opencollective.com/verdaccio/sponsor/9/website)
|
|
36
|
-
|
|
37
|
-
## Open Collective Backers
|
|
38
|
-
|
|
39
|
-
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/verdaccio#backer)]
|
|
40
|
-
|
|
41
|
-
[](https://opencollective.com/verdaccio#backers)
|
|
42
|
-
|
|
43
|
-
## Special Thanks
|
|
44
|
-
|
|
45
|
-
Thanks to the following companies to help us to achieve our goals providing free open source licenses.
|
|
46
|
-
|
|
47
|
-
[](https://www.jetbrains.com/)
|
|
48
|
-
[](https://crowdin.com/)
|
|
49
|
-
[](https://balsamiq.com/)
|
|
50
|
-
|
|
51
|
-
## Contributors
|
|
52
|
-
|
|
53
|
-
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
|
|
54
|
-
|
|
55
|
-
[](../../graphs/contributors)
|
|
56
|
-
|
|
57
|
-
### FAQ / Contact / Troubleshoot
|
|
58
|
-
|
|
59
|
-
If you have any issue you can try the following options, do no desist to ask or check our issues database, perhaps someone has asked already what you are looking for.
|
|
60
|
-
|
|
61
|
-
- [Blog](https://verdaccio.org/blog/)
|
|
62
|
-
- [Donations](https://opencollective.com/verdaccio)
|
|
63
|
-
- [Reporting an issue](https://github.com/verdaccio/verdaccio/blob/master/CONTRIBUTING.md#reporting-a-bug)
|
|
64
|
-
- [Running discussions](https://github.com/verdaccio/verdaccio/issues?q=is%3Aissue+is%3Aopen+label%3Adiscuss)
|
|
65
|
-
- [Chat](http://chat.verdaccio.org/)
|
|
66
|
-
- [Logos](https://verdaccio.org/docs/en/logo)
|
|
67
|
-
- [Docker Examples](https://github.com/verdaccio/docker-examples)
|
|
68
|
-
- [FAQ](https://github.com/verdaccio/verdaccio/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3Aquestion%20)
|
|
69
|
-
|
|
70
3
|
### License
|
|
71
4
|
|
|
72
5
|
Verdaccio is [MIT licensed](https://github.com/verdaccio/verdaccio/blob/master/LICENSE)
|
package/build/server.d.ts
CHANGED
|
@@ -17,12 +17,14 @@ export declare function initServer(config: ConfigYaml, port: string | void, vers
|
|
|
17
17
|
/**
|
|
18
18
|
* Exposes a server factory to be instantiated programmatically.
|
|
19
19
|
*
|
|
20
|
+
```ts
|
|
20
21
|
const app = await runServer(); // default configuration
|
|
21
22
|
const app = await runServer('./config/config.yaml');
|
|
22
23
|
const app = await runServer({ configuration });
|
|
23
24
|
app.listen(4000, (event) => {
|
|
24
25
|
// do something
|
|
25
26
|
});
|
|
27
|
+
```
|
|
26
28
|
* @param config
|
|
27
29
|
*/
|
|
28
30
|
export declare function runServer(config?: string | ConfigYaml): Promise<any>;
|
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.
|
|
183
|
+
logger.info('received shutdown signal - closing server gracefully...');
|
|
184
184
|
serverFactory.close(() => {
|
|
185
185
|
logger.info('server closed.');
|
|
186
186
|
process.exit(0);
|
|
@@ -197,12 +197,14 @@ async function initServer(config, port, version, pkgName) {
|
|
|
197
197
|
/**
|
|
198
198
|
* Exposes a server factory to be instantiated programmatically.
|
|
199
199
|
*
|
|
200
|
+
```ts
|
|
200
201
|
const app = await runServer(); // default configuration
|
|
201
202
|
const app = await runServer('./config/config.yaml');
|
|
202
203
|
const app = await runServer({ configuration });
|
|
203
204
|
app.listen(4000, (event) => {
|
|
204
205
|
// do something
|
|
205
206
|
});
|
|
207
|
+
```
|
|
206
208
|
* @param config
|
|
207
209
|
*/
|
|
208
210
|
|
package/build/server.js.map
CHANGED
|
@@ -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,UA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,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 ```ts\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 ```\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;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,CAAnB;MAKA,MAAMC,aAAa,GAAGT,MAAM,CAACU,KAA7B;MACA,MAAMC,SAAS,GAAGX,MAAM,CAACU,KAAzB,CAPE,CASF;;MACA,IAAI,EAAGD,aAAa,CAACG,GAAd,IAAqBH,aAAa,CAACI,IAApC,IAA6CF,SAAS,CAACG,GAAzD,CAAJ,EAAmE;QACjE;QACA,MAAMC,KAAK,CAAC,gCAAD,CAAX;MACD;;MAED,IAAIJ,SAAS,CAACG,GAAd,EAAmB;QACjB,MAAM;UAAEA,GAAF;UAAOE;QAAP,IAAsBL,SAA5B;QACAP,YAAY,GAAG,IAAAa,cAAA,EAAOb,YAAP,E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AC,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,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.
|
|
3
|
+
"version": "6.0.0-6-next.49",
|
|
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.
|
|
34
|
-
"@verdaccio/config": "6.0.0-6-next.
|
|
35
|
-
"@verdaccio/logger": "6.0.0-6-next.
|
|
36
|
-
"@verdaccio/server": "6.0.0-6-next.
|
|
37
|
-
"@verdaccio/server-fastify": "6.0.0-6-next.
|
|
38
|
-
"core-js": "3.25.
|
|
33
|
+
"@verdaccio/core": "6.0.0-6-next.49",
|
|
34
|
+
"@verdaccio/config": "6.0.0-6-next.49",
|
|
35
|
+
"@verdaccio/logger": "6.0.0-6-next.17",
|
|
36
|
+
"@verdaccio/server": "6.0.0-6-next.38",
|
|
37
|
+
"@verdaccio/server-fastify": "6.0.0-6-next.30",
|
|
38
|
+
"core-js": "3.25.3",
|
|
39
39
|
"debug": "4.3.4",
|
|
40
40
|
"lodash": "4.17.21"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@types/node": "16.11.
|
|
44
|
-
"@verdaccio/types": "11.0.0-6-next.
|
|
43
|
+
"@types/node": "16.11.62",
|
|
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"
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"build": "pnpm run build:js && pnpm run build:types",
|
|
63
63
|
"test": "jest"
|
|
64
64
|
},
|
|
65
|
-
"readme": "# @verdaccio/node-api\n\n
|
|
65
|
+
"readme": "# @verdaccio/node-api\n\n### License\n\nVerdaccio is [MIT licensed](https://github.com/verdaccio/verdaccio/blob/master/LICENSE)\n\nThe Verdaccio documentation and logos (excluding /thanks, e.g., .md, .png, .sketch) files within the /assets folder) is\n[Creative Commons licensed](https://github.com/verdaccio/verdaccio/blob/master/LICENSE-docs).\n"
|
|
66
66
|
}
|
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
|
|
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
|
|
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.
|
|
158
|
+
logger.info('received shutdown signal - closing server gracefully...');
|
|
159
159
|
serverFactory.close(() => {
|
|
160
160
|
logger.info('server closed.');
|
|
161
161
|
process.exit(0);
|
|
@@ -173,12 +173,14 @@ export async function initServer(
|
|
|
173
173
|
/**
|
|
174
174
|
* Exposes a server factory to be instantiated programmatically.
|
|
175
175
|
*
|
|
176
|
+
```ts
|
|
176
177
|
const app = await runServer(); // default configuration
|
|
177
178
|
const app = await runServer('./config/config.yaml');
|
|
178
179
|
const app = await runServer({ configuration });
|
|
179
180
|
app.listen(4000, (event) => {
|
|
180
181
|
// do something
|
|
181
182
|
});
|
|
183
|
+
```
|
|
182
184
|
* @param config
|
|
183
185
|
*/
|
|
184
186
|
export async function runServer(config?: string | ConfigYaml): Promise<any> {
|
|
@@ -196,6 +198,6 @@ export async function runServer(config?: string | ConfigYaml): Promise<any> {
|
|
|
196
198
|
displayExperimentsInfoBox(configurationParsed.flags);
|
|
197
199
|
// FIXME: get only the first match, the multiple address will be removed
|
|
198
200
|
const [addr] = getListListenAddresses(undefined, configurationParsed.listen);
|
|
199
|
-
const app = await
|
|
201
|
+
const app = await expressServer(configurationParsed);
|
|
200
202
|
return createServerFactory(configurationParsed, addr, app);
|
|
201
203
|
}
|
package/test/run-server.spec.ts
CHANGED
package/tsconfig.build.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -4,21 +4,15 @@
|
|
|
4
4
|
"rootDir": "./src",
|
|
5
5
|
"outDir": "./build"
|
|
6
6
|
},
|
|
7
|
-
"include": ["src
|
|
7
|
+
"include": ["src/**/*.ts", "types/*.d.ts"],
|
|
8
8
|
"exclude": ["src/**/*.test.ts"],
|
|
9
9
|
"references": [
|
|
10
10
|
{
|
|
11
11
|
"path": "../config"
|
|
12
12
|
},
|
|
13
|
-
{
|
|
14
|
-
"path": "../core/cli-ui"
|
|
15
|
-
},
|
|
16
13
|
{
|
|
17
14
|
"path": "../logger"
|
|
18
15
|
},
|
|
19
|
-
{
|
|
20
|
-
"path": "../mock"
|
|
21
|
-
},
|
|
22
16
|
{
|
|
23
17
|
"path": "../server/express"
|
|
24
18
|
},
|