@verdaccio/node-api 8.0.0-next-8.12 → 8.0.0-next-8.13
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/README.md +76 -4
- package/package.json +13 -9
- package/.babelrc +0 -3
- package/CHANGELOG.md +0 -1697
- package/examples/.eslintrc +0 -5
- package/examples/default.configuration.example.js +0 -8
- package/src/cli-utils.ts +0 -84
- package/src/experiments.ts +0 -23
- package/src/index.ts +0 -1
- package/src/server.ts +0 -217
- package/test/node-api.utils.spec.ts +0 -68
- package/test/parseAddress.spec.ts +0 -52
- package/test/partials/config/yaml/server/keepalivetimeout-0.yaml +0 -2
- package/test/partials/config/yaml/server/keepalivetimeout-60.yaml +0 -2
- package/test/partials/config/yaml/server/keepalivetimeout-undefined.yaml +0 -2
- package/test/run-server.spec.ts +0 -23
- package/tsconfig.build.json +0 -8
- package/tsconfig.json +0 -23
package/examples/.eslintrc
DELETED
package/src/cli-utils.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { warningUtils } from '@verdaccio/core';
|
|
2
|
-
|
|
3
|
-
export const DEFAULT_PORT = '4873';
|
|
4
|
-
export const DEFAULT_PROTOCOL = 'http';
|
|
5
|
-
export const DEFAULT_DOMAIN = 'localhost';
|
|
6
|
-
/**
|
|
7
|
-
* Parse an internet address
|
|
8
|
-
* Allow:
|
|
9
|
-
- https:localhost:1234 - protocol + host + port
|
|
10
|
-
- localhost:1234 - host + port
|
|
11
|
-
- 1234 - port
|
|
12
|
-
- http::1234 - protocol + port
|
|
13
|
-
- https://localhost:443/ - full url + https
|
|
14
|
-
- http://[::1]:443/ - ipv6
|
|
15
|
-
- unix:/tmp/http.sock - unix sockets
|
|
16
|
-
- https://unix:/tmp/http.sock - unix sockets (https)
|
|
17
|
-
* @param {*} urlAddress the internet address definition
|
|
18
|
-
* @return {Object|Null} literal object that represent the address parsed
|
|
19
|
-
*/
|
|
20
|
-
export function parseAddress(urlAddress: any): any {
|
|
21
|
-
//
|
|
22
|
-
// TODO: refactor it to something more reasonable?
|
|
23
|
-
//
|
|
24
|
-
// protocol : // ( host )|( ipv6 ): port /
|
|
25
|
-
let urlPattern = /^((https?):(\/\/)?)?((([^\/:]*)|\[([^\[\]]+)\]):)?(\d+)\/?$/.exec(urlAddress);
|
|
26
|
-
|
|
27
|
-
if (urlPattern) {
|
|
28
|
-
return {
|
|
29
|
-
proto: urlPattern[2] || DEFAULT_PROTOCOL,
|
|
30
|
-
host: urlPattern[6] || urlPattern[7] || DEFAULT_DOMAIN,
|
|
31
|
-
port: urlPattern[8] || DEFAULT_PORT,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
urlPattern = /^((https?):(\/\/)?)?unix:(.*)$/.exec(urlAddress);
|
|
36
|
-
|
|
37
|
-
if (urlPattern) {
|
|
38
|
-
return {
|
|
39
|
-
proto: urlPattern[2] || DEFAULT_PROTOCOL,
|
|
40
|
-
path: urlPattern[4],
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Retrieve all addresses defined in the config file.
|
|
49
|
-
* Verdaccio is able to listen multiple ports
|
|
50
|
-
* @param {String} argListen
|
|
51
|
-
* @param {String} configListen
|
|
52
|
-
* eg:
|
|
53
|
-
* listen:
|
|
54
|
-
- localhost:5555
|
|
55
|
-
- localhost:5557
|
|
56
|
-
@return {Array}
|
|
57
|
-
*/
|
|
58
|
-
export function getListListenAddresses(argListen: string | void, configListen: any): any {
|
|
59
|
-
// command line || config file || default
|
|
60
|
-
let addresses;
|
|
61
|
-
if (argListen) {
|
|
62
|
-
addresses = [argListen];
|
|
63
|
-
} else if (Array.isArray(configListen)) {
|
|
64
|
-
addresses = configListen;
|
|
65
|
-
process.emitWarning('multiple addresses will be deprecated in the next major, only use one');
|
|
66
|
-
} else if (configListen) {
|
|
67
|
-
addresses = [configListen];
|
|
68
|
-
} else {
|
|
69
|
-
addresses = [DEFAULT_PORT];
|
|
70
|
-
}
|
|
71
|
-
addresses = addresses
|
|
72
|
-
.map(function (addr): string {
|
|
73
|
-
const parsedAddr = parseAddress(addr);
|
|
74
|
-
|
|
75
|
-
if (!parsedAddr) {
|
|
76
|
-
warningUtils.emit(warningUtils.Codes.VERWAR004, addr);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return parsedAddr;
|
|
80
|
-
})
|
|
81
|
-
.filter(Boolean);
|
|
82
|
-
|
|
83
|
-
return addresses;
|
|
84
|
-
}
|
package/src/experiments.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { logger } from '@verdaccio/logger';
|
|
2
|
-
|
|
3
|
-
export function displayExperimentsInfoBox(flags) {
|
|
4
|
-
if (!flags) {
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const experimentList = Object.keys(flags);
|
|
9
|
-
if (experimentList.length >= 1) {
|
|
10
|
-
logger.warn(
|
|
11
|
-
// eslint-disable-next-line max-len
|
|
12
|
-
`experiments are enabled, it is recommended do not use experiments in production comment out this section to disable it`
|
|
13
|
-
);
|
|
14
|
-
experimentList.forEach((experiment) => {
|
|
15
|
-
// eslint-disable-next-line max-len
|
|
16
|
-
logger.info(
|
|
17
|
-
`support for experiment [${experiment}] ${
|
|
18
|
-
flags[experiment] ? 'is enabled' : ' is disabled'
|
|
19
|
-
}`
|
|
20
|
-
);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { initServer, runServer } from './server';
|
package/src/server.ts
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
import constants from 'constants';
|
|
3
|
-
import buildDebug from 'debug';
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import http from 'http';
|
|
6
|
-
import https from 'https';
|
|
7
|
-
import _, { assign, isFunction } from 'lodash';
|
|
8
|
-
import url from 'url';
|
|
9
|
-
|
|
10
|
-
import { findConfigFile, parseConfigFile } from '@verdaccio/config';
|
|
11
|
-
import { API_ERROR } from '@verdaccio/core';
|
|
12
|
-
import { setup } from '@verdaccio/logger';
|
|
13
|
-
import expressServer from '@verdaccio/server';
|
|
14
|
-
import fastifyServer from '@verdaccio/server-fastify';
|
|
15
|
-
import { ConfigYaml, HttpsConfKeyCert, HttpsConfPfx } from '@verdaccio/types';
|
|
16
|
-
|
|
17
|
-
import { getListListenAddresses } from './cli-utils';
|
|
18
|
-
import { displayExperimentsInfoBox } from './experiments';
|
|
19
|
-
|
|
20
|
-
const debug = buildDebug('verdaccio:node-api');
|
|
21
|
-
|
|
22
|
-
function unlinkAddressPath(addr) {
|
|
23
|
-
if (addr.path && fs.existsSync(addr.path)) {
|
|
24
|
-
fs.unlinkSync(addr.path);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Return a native HTTP/HTTPS server instance
|
|
30
|
-
* @param config
|
|
31
|
-
* @param addr
|
|
32
|
-
* @param app
|
|
33
|
-
*/
|
|
34
|
-
export function createServerFactory(config: ConfigYaml, addr, app) {
|
|
35
|
-
let serverFactory;
|
|
36
|
-
if (addr.proto === 'https') {
|
|
37
|
-
debug('https enabled');
|
|
38
|
-
try {
|
|
39
|
-
let httpsOptions = {
|
|
40
|
-
// disable insecure SSLv2 and SSLv3
|
|
41
|
-
secureOptions: constants.SSL_OP_NO_SSLv2 | constants.SSL_OP_NO_SSLv3,
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const keyCertConfig = config.https as HttpsConfKeyCert;
|
|
45
|
-
const pfxConfig = config.https as HttpsConfPfx;
|
|
46
|
-
|
|
47
|
-
// https must either have key and cert or a pfx and (optionally) a passphrase
|
|
48
|
-
if (!((keyCertConfig.key && keyCertConfig.cert) || pfxConfig.pfx)) {
|
|
49
|
-
// logHTTPSError(configPath);
|
|
50
|
-
throw Error('bad format https configuration');
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (pfxConfig.pfx) {
|
|
54
|
-
const { pfx, passphrase } = pfxConfig;
|
|
55
|
-
httpsOptions = assign(httpsOptions, {
|
|
56
|
-
pfx: fs.readFileSync(pfx),
|
|
57
|
-
passphrase: passphrase || '',
|
|
58
|
-
});
|
|
59
|
-
} else {
|
|
60
|
-
const { key, cert, ca } = keyCertConfig;
|
|
61
|
-
httpsOptions = assign(httpsOptions, {
|
|
62
|
-
key: fs.readFileSync(key),
|
|
63
|
-
cert: fs.readFileSync(cert),
|
|
64
|
-
...(ca && {
|
|
65
|
-
ca: fs.readFileSync(ca),
|
|
66
|
-
}),
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
// TODO: enable http2 as feature
|
|
70
|
-
// if (config.server.http2) <-- check if force http2
|
|
71
|
-
serverFactory = https.createServer(httpsOptions, app);
|
|
72
|
-
} catch (err: any) {
|
|
73
|
-
throw new Error(`cannot create https server: ${err.message}`);
|
|
74
|
-
}
|
|
75
|
-
} else {
|
|
76
|
-
// http
|
|
77
|
-
debug('http enabled');
|
|
78
|
-
serverFactory = http.createServer(app);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// List of all routes registered in the app
|
|
82
|
-
function printRoutes(layer) {
|
|
83
|
-
if (layer.route) {
|
|
84
|
-
debug('%s (%s)', layer.route.path, Object.keys(layer.route.methods).join(', '));
|
|
85
|
-
} else if (layer.name === 'router') {
|
|
86
|
-
layer.handle.stack.forEach((nestedLayer) => {
|
|
87
|
-
printRoutes(nestedLayer);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
debug('registered routes:');
|
|
93
|
-
app._router.stack.forEach(printRoutes);
|
|
94
|
-
|
|
95
|
-
if (
|
|
96
|
-
config.server &&
|
|
97
|
-
typeof config.server.keepAliveTimeout !== 'undefined' &&
|
|
98
|
-
// @ts-ignore
|
|
99
|
-
config.server.keepAliveTimeout !== 'null'
|
|
100
|
-
) {
|
|
101
|
-
// library definition for node is not up to date (doesn't contain recent 8.0 changes)
|
|
102
|
-
serverFactory.keepAliveTimeout = config.server.keepAliveTimeout * 1000;
|
|
103
|
-
}
|
|
104
|
-
// FIXE: I could not find the reason of this code.
|
|
105
|
-
unlinkAddressPath(addr);
|
|
106
|
-
|
|
107
|
-
return serverFactory;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Start the server on the port defined
|
|
112
|
-
* @param config
|
|
113
|
-
* @param port
|
|
114
|
-
* @param version
|
|
115
|
-
* @param pkgName
|
|
116
|
-
*/
|
|
117
|
-
export async function initServer(
|
|
118
|
-
config: ConfigYaml,
|
|
119
|
-
port: string | void,
|
|
120
|
-
version: string,
|
|
121
|
-
pkgName: string
|
|
122
|
-
): Promise<void> {
|
|
123
|
-
return new Promise(async (resolve, reject) => {
|
|
124
|
-
// FIXME: get only the first match, the multiple address will be removed
|
|
125
|
-
const [addr] = getListListenAddresses(port, config.listen);
|
|
126
|
-
const logger = setup(config?.log as any);
|
|
127
|
-
displayExperimentsInfoBox(config.flags);
|
|
128
|
-
|
|
129
|
-
let app;
|
|
130
|
-
if (process.env.VERDACCIO_SERVER === 'fastify') {
|
|
131
|
-
app = await fastifyServer(config);
|
|
132
|
-
app.listen({ port: addr.port, host: addr.host }, (err) => {
|
|
133
|
-
if (err) {
|
|
134
|
-
reject(err);
|
|
135
|
-
} else {
|
|
136
|
-
resolve();
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
} else {
|
|
140
|
-
app = await expressServer(config);
|
|
141
|
-
const serverFactory = createServerFactory(config, addr, app);
|
|
142
|
-
serverFactory
|
|
143
|
-
.listen(addr.port || addr.path, addr.host, (): void => {
|
|
144
|
-
// send a message for test
|
|
145
|
-
if (isFunction(process.send)) {
|
|
146
|
-
process.send({
|
|
147
|
-
verdaccio_started: true,
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
const addressServer = `${
|
|
151
|
-
addr.path
|
|
152
|
-
? url.format({
|
|
153
|
-
protocol: 'unix',
|
|
154
|
-
pathname: addr.path,
|
|
155
|
-
})
|
|
156
|
-
: url.format({
|
|
157
|
-
protocol: addr.proto,
|
|
158
|
-
hostname: addr.host,
|
|
159
|
-
port: addr.port,
|
|
160
|
-
pathname: '/',
|
|
161
|
-
})
|
|
162
|
-
}`;
|
|
163
|
-
logger.info({ addressServer }, 'http address: @{addressServer}');
|
|
164
|
-
logger.info({ version }, 'version: @{version}');
|
|
165
|
-
resolve();
|
|
166
|
-
})
|
|
167
|
-
.on('error', function (err): void {
|
|
168
|
-
reject(err);
|
|
169
|
-
process.exitCode = 1;
|
|
170
|
-
});
|
|
171
|
-
function handleShutdownGracefully() {
|
|
172
|
-
logger.info('received shutdown signal - closing server gracefully...');
|
|
173
|
-
serverFactory.close(() => {
|
|
174
|
-
logger.info('server closed.');
|
|
175
|
-
process.exit(0);
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) {
|
|
180
|
-
// Use once() so that receiving double signals exit the app.
|
|
181
|
-
process.once(signal, handleShutdownGracefully);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Exposes a server factory to be instantiated programmatically.
|
|
189
|
-
*
|
|
190
|
-
```ts
|
|
191
|
-
const app = await runServer(); // default configuration
|
|
192
|
-
const app = await runServer('./config/config.yaml');
|
|
193
|
-
const app = await runServer({ configuration });
|
|
194
|
-
app.listen(4000, (event) => {
|
|
195
|
-
// do something
|
|
196
|
-
});
|
|
197
|
-
```
|
|
198
|
-
* @param config
|
|
199
|
-
*/
|
|
200
|
-
export async function runServer(config?: string | ConfigYaml): Promise<any> {
|
|
201
|
-
let configurationParsed: ConfigYaml;
|
|
202
|
-
if (config === undefined || typeof config === 'string') {
|
|
203
|
-
const configPathLocation = findConfigFile(config);
|
|
204
|
-
configurationParsed = parseConfigFile(configPathLocation);
|
|
205
|
-
} else if (_.isObject(config)) {
|
|
206
|
-
configurationParsed = config;
|
|
207
|
-
} else {
|
|
208
|
-
throw new Error(API_ERROR.CONFIG_BAD_FORMAT);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
setup(configurationParsed.log as any);
|
|
212
|
-
displayExperimentsInfoBox(configurationParsed.flags);
|
|
213
|
-
// FIXME: get only the first match, the multiple address will be removed
|
|
214
|
-
const [addr] = getListListenAddresses(undefined, configurationParsed.listen);
|
|
215
|
-
const app = await expressServer(configurationParsed);
|
|
216
|
-
return createServerFactory(configurationParsed, addr, app);
|
|
217
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import _ from 'lodash';
|
|
2
|
-
import { describe, expect, test } from 'vitest';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
DEFAULT_DOMAIN,
|
|
6
|
-
DEFAULT_PORT,
|
|
7
|
-
DEFAULT_PROTOCOL,
|
|
8
|
-
getListListenAddresses,
|
|
9
|
-
} from '../src/cli-utils';
|
|
10
|
-
|
|
11
|
-
describe('getListListenAddresses test', () => {
|
|
12
|
-
test('should return no address if a single address is wrong', () => {
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
const addrs = getListListenAddresses('wrong');
|
|
15
|
-
|
|
16
|
-
expect(_.isArray(addrs)).toBeTruthy();
|
|
17
|
-
expect(addrs).toHaveLength(0);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test('should return no address if a two address are wrong', () => {
|
|
21
|
-
// @ts-ignore
|
|
22
|
-
const addrs = getListListenAddresses(['wrong', 'same-wrong']);
|
|
23
|
-
|
|
24
|
-
expect(_.isArray(addrs)).toBeTruthy();
|
|
25
|
-
expect(addrs).toHaveLength(0);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test('should return a list of 1 address provided', () => {
|
|
29
|
-
// @ts-ignore
|
|
30
|
-
const addrs = getListListenAddresses(null, '1000');
|
|
31
|
-
|
|
32
|
-
expect(_.isArray(addrs)).toBeTruthy();
|
|
33
|
-
expect(addrs).toHaveLength(1);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test('should return a list of 2 address provided', () => {
|
|
37
|
-
// @ts-ignore
|
|
38
|
-
const addrs = getListListenAddresses(null, ['1000', '2000']);
|
|
39
|
-
|
|
40
|
-
expect(_.isArray(addrs)).toBeTruthy();
|
|
41
|
-
expect(addrs).toHaveLength(2);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test(`should return by default ${DEFAULT_PORT}`, () => {
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
const [addrs] = getListListenAddresses();
|
|
47
|
-
|
|
48
|
-
// @ts-ignore
|
|
49
|
-
expect(addrs.proto).toBe(DEFAULT_PROTOCOL);
|
|
50
|
-
// @ts-ignore
|
|
51
|
-
expect(addrs.host).toBe(DEFAULT_DOMAIN);
|
|
52
|
-
// @ts-ignore
|
|
53
|
-
expect(addrs.port).toBe(DEFAULT_PORT);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test('should return default proto, host and custom port', () => {
|
|
57
|
-
const initPort = '1000';
|
|
58
|
-
// @ts-ignore
|
|
59
|
-
const [addrs] = getListListenAddresses(null, initPort);
|
|
60
|
-
|
|
61
|
-
// @ts-ignore
|
|
62
|
-
expect(addrs.proto).toEqual(DEFAULT_PROTOCOL);
|
|
63
|
-
// @ts-ignore
|
|
64
|
-
expect(addrs.host).toEqual(DEFAULT_DOMAIN);
|
|
65
|
-
// @ts-ignore
|
|
66
|
-
expect(addrs.port).toEqual(initPort);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import _ from 'lodash';
|
|
2
|
-
import { describe, expect, test } from 'vitest';
|
|
3
|
-
|
|
4
|
-
import { DEFAULT_DOMAIN, DEFAULT_PORT, parseAddress } from '../src/cli-utils';
|
|
5
|
-
|
|
6
|
-
describe('Parse listen address', () => {
|
|
7
|
-
const useCases: any[] = [];
|
|
8
|
-
|
|
9
|
-
function addTest(uri: string, proto: string | null, host?: string, port?: string) {
|
|
10
|
-
useCases.push([uri, proto, host, port]);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
addTest(DEFAULT_PORT, 'http', DEFAULT_DOMAIN, DEFAULT_PORT);
|
|
14
|
-
addTest(':4873', 'http', DEFAULT_DOMAIN, DEFAULT_PORT);
|
|
15
|
-
addTest('blah:4873', 'http', 'blah', DEFAULT_PORT);
|
|
16
|
-
addTest('http://:4873', 'http', DEFAULT_DOMAIN, DEFAULT_PORT);
|
|
17
|
-
addTest('https::4873', 'https', DEFAULT_DOMAIN, DEFAULT_PORT);
|
|
18
|
-
addTest('https:blah:4873', 'https', 'blah', DEFAULT_PORT);
|
|
19
|
-
addTest('https://blah:4873/', 'https', 'blah', DEFAULT_PORT);
|
|
20
|
-
addTest('[::1]:4873', 'http', '::1', DEFAULT_PORT);
|
|
21
|
-
addTest('https:[::1]:4873', 'https', '::1', DEFAULT_PORT);
|
|
22
|
-
|
|
23
|
-
addTest('unix:/tmp/foo.sock', 'http', '/tmp/foo.sock');
|
|
24
|
-
addTest('http:unix:foo.sock', 'http', 'foo.sock');
|
|
25
|
-
addTest('https://unix:foo.sock', 'https', 'foo.sock');
|
|
26
|
-
addTest('https://unix:foo.sock:34', 'https', 'foo.sock:34');
|
|
27
|
-
addTest('http://foo.sock:34', 'http', 'foo.sock', '34');
|
|
28
|
-
|
|
29
|
-
addTest('blah', null);
|
|
30
|
-
addTest('blah://4873', null);
|
|
31
|
-
addTest('https://blah:4873///', null);
|
|
32
|
-
addTest('unix:1234', 'http', 'unix', '1234'); // not unix socket
|
|
33
|
-
|
|
34
|
-
test.each(useCases)(`should parse (%s - %s - %s - %s)`, (uri, proto, host, port) => {
|
|
35
|
-
const parsed = parseAddress(uri);
|
|
36
|
-
|
|
37
|
-
if (_.isNull(proto)) {
|
|
38
|
-
expect(parsed).toBeNull();
|
|
39
|
-
} else if (port) {
|
|
40
|
-
expect(parsed).toEqual({
|
|
41
|
-
proto,
|
|
42
|
-
host,
|
|
43
|
-
port,
|
|
44
|
-
});
|
|
45
|
-
} else {
|
|
46
|
-
expect(parsed).toEqual({
|
|
47
|
-
proto,
|
|
48
|
-
path: host,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
});
|
package/test/run-server.spec.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import request from 'supertest';
|
|
2
|
-
import { describe, expect, test } from 'vitest';
|
|
3
|
-
|
|
4
|
-
import { runServer } from '../src';
|
|
5
|
-
|
|
6
|
-
describe('startServer via API', () => {
|
|
7
|
-
// TODO: fix this test does not runs with vitest
|
|
8
|
-
test.skip('should provide all HTTP server data', async () => {
|
|
9
|
-
const webServer = await runServer();
|
|
10
|
-
expect(webServer).toBeDefined();
|
|
11
|
-
await request(webServer).get('/').expect(200);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test('should fail on start with empty configuration', async () => {
|
|
15
|
-
// @ts-expect-error
|
|
16
|
-
await expect(runServer({})).rejects.toThrow('configPath property is required');
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test('should fail on start with null as entry', async () => {
|
|
20
|
-
// @ts-expect-error
|
|
21
|
-
await expect(runServer(null)).rejects.toThrow();
|
|
22
|
-
});
|
|
23
|
-
});
|
package/tsconfig.build.json
DELETED
package/tsconfig.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.reference.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"rootDir": "./src",
|
|
5
|
-
"outDir": "./build"
|
|
6
|
-
},
|
|
7
|
-
"include": ["src/**/*.ts", "types/*.d.ts"],
|
|
8
|
-
"exclude": ["src/**/*.test.ts"],
|
|
9
|
-
"references": [
|
|
10
|
-
{
|
|
11
|
-
"path": "../config"
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"path": "../logger/logger"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"path": "../server/express"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"path": "../server/fastify"
|
|
21
|
-
}
|
|
22
|
-
]
|
|
23
|
-
}
|