@rest-vir/run-service 0.3.3 → 0.4.0
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.
|
@@ -80,4 +80,4 @@ export type StartServiceUserOptions = PartialWithUndefined<StartServiceOptions>;
|
|
|
80
80
|
* @package [`@rest-vir/run-service`](https://www.npmjs.com/package/@rest-vir/run-service)
|
|
81
81
|
* @see {@link startServiceOptionsShape} for option explanations.
|
|
82
82
|
*/
|
|
83
|
-
export declare function finalizeOptions(userOptions: Readonly<StartServiceUserOptions>): StartServiceOptions;
|
|
83
|
+
export declare function finalizeOptions(serviceOrigin: string, userOptions: Readonly<StartServiceUserOptions>): StartServiceOptions;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { mergeDefinedProperties } from '@augment-vir/common';
|
|
2
2
|
import { cpus } from 'node:os';
|
|
3
3
|
import { assertValidShape, defineShape } from 'object-shape-tester';
|
|
4
|
+
import { parseUrl } from 'url-vir';
|
|
4
5
|
/**
|
|
5
6
|
* Shape definition for `startService` options.
|
|
6
7
|
*
|
|
@@ -65,8 +66,14 @@ export const startServiceOptionsShape = defineShape({
|
|
|
65
66
|
* @package [`@rest-vir/run-service`](https://www.npmjs.com/package/@rest-vir/run-service)
|
|
66
67
|
* @see {@link startServiceOptionsShape} for option explanations.
|
|
67
68
|
*/
|
|
68
|
-
export function finalizeOptions(userOptions) {
|
|
69
|
-
const
|
|
69
|
+
export function finalizeOptions(serviceOrigin, userOptions) {
|
|
70
|
+
const { hostname, port } = parseUrl(serviceOrigin);
|
|
71
|
+
const options = mergeDefinedProperties(startServiceOptionsShape.defaultValue, Number(port)
|
|
72
|
+
? {
|
|
73
|
+
host: hostname || undefined,
|
|
74
|
+
port: Number(port),
|
|
75
|
+
}
|
|
76
|
+
: {}, userOptions);
|
|
70
77
|
options.workerCount = Math.max(1, options.workerCount);
|
|
71
78
|
assertValidShape(options, startServiceOptionsShape);
|
|
72
79
|
return options;
|
|
@@ -60,4 +60,4 @@ export declare function startService(service: Readonly<SelectFrom<GenericService
|
|
|
60
60
|
serviceOrigin: true;
|
|
61
61
|
requiredClientOrigin: true;
|
|
62
62
|
logger: true;
|
|
63
|
-
}>>, userOptions
|
|
63
|
+
}>>, userOptions?: Readonly<StartServiceUserOptions>): Promise<StartServiceOutput>;
|
|
@@ -14,8 +14,8 @@ import { finalizeOptions, } from './start-service-options.js';
|
|
|
14
14
|
* @category Package : @rest-vir/run-service
|
|
15
15
|
* @package [`@rest-vir/run-service`](https://www.npmjs.com/package/@rest-vir/run-service)
|
|
16
16
|
*/
|
|
17
|
-
export async function startService(service, userOptions) {
|
|
18
|
-
const options = finalizeOptions(userOptions);
|
|
17
|
+
export async function startService(service, userOptions = {}) {
|
|
18
|
+
const options = finalizeOptions(service.serviceOrigin, userOptions);
|
|
19
19
|
const port = options.lockPort || check.isFalse(options.port)
|
|
20
20
|
? options.port
|
|
21
21
|
: await getPortPromise({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rest-vir/run-service",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Run a service defined by @rest-vir/define-service and implemented by @rest-vir/implement-service.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rest",
|
|
@@ -39,29 +39,29 @@
|
|
|
39
39
|
"test:update": "npm test update"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@augment-vir/assert": "^31.9.
|
|
43
|
-
"@augment-vir/common": "^31.9.
|
|
44
|
-
"@augment-vir/node": "^31.9.
|
|
42
|
+
"@augment-vir/assert": "^31.9.4",
|
|
43
|
+
"@augment-vir/common": "^31.9.4",
|
|
44
|
+
"@augment-vir/node": "^31.9.4",
|
|
45
45
|
"@fastify/websocket": "^11.0.2",
|
|
46
|
-
"@rest-vir/define-service": "^0.
|
|
47
|
-
"@rest-vir/implement-service": "^0.
|
|
46
|
+
"@rest-vir/define-service": "^0.4.0",
|
|
47
|
+
"@rest-vir/implement-service": "^0.4.0",
|
|
48
48
|
"cluster-vir": "^0.1.0",
|
|
49
49
|
"date-vir": "^7.2.1",
|
|
50
50
|
"fastify": "^5.2.1",
|
|
51
51
|
"light-my-request": "^6.6.0",
|
|
52
|
-
"portfinder": "^1.0.
|
|
53
|
-
"type-fest": "^4.
|
|
54
|
-
"url-vir": "^2.1.
|
|
52
|
+
"portfinder": "^1.0.33",
|
|
53
|
+
"type-fest": "^4.37.0",
|
|
54
|
+
"url-vir": "^2.1.3"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@augment-vir/test": "^31.9.
|
|
57
|
+
"@augment-vir/test": "^31.9.4",
|
|
58
58
|
"@types/connect": "^3.4.38",
|
|
59
|
-
"@types/node": "^22.13.
|
|
60
|
-
"@types/ws": "^8.
|
|
59
|
+
"@types/node": "^22.13.9",
|
|
60
|
+
"@types/ws": "^8.18.0",
|
|
61
61
|
"c8": "^10.1.3",
|
|
62
62
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
63
63
|
"markdown-code-example-inserter": "^3.0.3",
|
|
64
|
-
"object-shape-tester": "^5.1.
|
|
64
|
+
"object-shape-tester": "^5.1.4"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"object-shape-tester": ">=5"
|