@sigodenjs/dee-srv-create
Advanced tools
Comparing version 0.17.1 to 0.18.1
@@ -1,2 +0,2 @@ | ||
import { SrvContext, InitFn, Ctor, Stop } from "@sigodenjs/dee-srv"; | ||
import { SrvContext, InitFn, Ctor } from "@sigodenjs/dee-srv"; | ||
export declare type ServiceOptionMap = { | ||
@@ -11,9 +11,5 @@ [k: string]: ServiceOption<any, any, any>; | ||
} | ||
export interface CreateSrvOutput<T> { | ||
srv: T; | ||
stop: Stop; | ||
} | ||
export declare function createSrvs(ctx: SrvContext, services?: ServiceOptionMap): Promise<Stop[]>; | ||
export declare function createSrv<T, U>(ctx: SrvContext, srvName: string, options: ServiceOption<T, U>): Promise<CreateSrvOutput<T>>; | ||
export declare function createSrvs(ctx: SrvContext, services?: ServiceOptionMap): Promise<void>; | ||
export declare function createSrv<T, U>(ctx: SrvContext, srvName: string, options: ServiceOption<T, U>): Promise<T>; | ||
export declare class ServiceCreateError extends Error { | ||
} |
@@ -12,2 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const dee_srv_1 = require("@sigodenjs/dee-srv"); | ||
const createDebug = require("debug"); | ||
@@ -19,3 +20,3 @@ const events_1 = require("events"); | ||
const event = new events_1.EventEmitter(); | ||
const stops = yield Promise.all(Object.keys(services).map(srvName => { | ||
yield Promise.all(Object.keys(services).map(srvName => { | ||
const options = services[srvName]; | ||
@@ -28,5 +29,5 @@ let deps = options.deps || []; | ||
createSrv(ctx, srvName, options) | ||
.then(o => { | ||
.then(() => { | ||
event.emit("ready", srvName); | ||
resolve(o.stop); | ||
resolve(); | ||
}).catch(err => { | ||
@@ -62,3 +63,2 @@ event.emit("error", err); | ||
event.removeAllListeners(); | ||
return stops; | ||
}); | ||
@@ -88,6 +88,9 @@ } | ||
} | ||
const { srv, stop = (() => { }) } = yield init(ctx, options.args, options.ctor, deps); | ||
const srv = yield init(ctx, options.args, options.ctor, deps); | ||
if (srv[dee_srv_1.INIT_KEY]) { | ||
yield srv[dee_srv_1.INIT_KEY](); | ||
} | ||
debug(`finish starting srv ${srvName}`); | ||
ctx.srvs[srvName] = srv; | ||
return { srv, stop }; | ||
return srv; | ||
} | ||
@@ -94,0 +97,0 @@ catch (err) { |
{ | ||
"name": "@sigodenjs/dee-srv-create", | ||
"version": "0.17.1", | ||
"version": "0.18.1", | ||
"description": "Utils for creating batch of dee-srvs", | ||
@@ -30,3 +30,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@sigodenjs/dee-srv": "^0.17.0" | ||
"@sigodenjs/dee-srv": "^0.18.0" | ||
}, | ||
@@ -33,0 +33,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8934
114
+ Added@sigodenjs/dee-srv@0.18.4(transitive)
- Removed@sigodenjs/dee-srv@0.17.0(transitive)
Updated@sigodenjs/dee-srv@^0.18.0