@common-stack/server-core
Advanced tools
Comparing version 0.0.152-0 to 0.0.152
import { IResolverOptions, IDirectiveOptions } from '../interfaces'; | ||
import { Container } from 'inversify'; | ||
export declare const featureCatalog: any; | ||
@@ -11,5 +12,3 @@ export declare type FeatureParams = { | ||
createContainerFunc?: Function | Function[]; | ||
preCreateServiceFunc?: Function | Function[]; | ||
updateContainerFunc?: any | any[]; | ||
createPreference?: Function | Function[]; | ||
createPreference?: any | any[]; | ||
overwritePreference?: Function | Function[]; | ||
@@ -29,4 +28,2 @@ dataIdFromObject?: Function | Function[]; | ||
createContainerFunc: Function[]; | ||
preCreateServiceFunc: Function[]; | ||
updateContainerFunc: any[]; | ||
beforeware: Function[]; | ||
@@ -36,13 +33,10 @@ middleware: Function[]; | ||
overwritePreference: Function[]; | ||
private services; | ||
private container; | ||
constructor(feature?: FeatureParams, ...features: Feature[]); | ||
readonly schemas: string[]; | ||
createContext(req: any, connectionParams: any, webSocket?: any): Promise<any>; | ||
createServiceContext(options: any, updateOptions?: any): (req: any, connectionParams: any, webSocket?: any) => Promise<any>; | ||
createService(options: any, updateOptions?: any): Promise<any>; | ||
createServiceContext(options: any): (req: any, connectionParams: any, webSocket?: any) => Promise<any>; | ||
createService(options: any): any; | ||
createResolvers(options?: IResolverOptions): any; | ||
createDirectives(options?: IDirectiveOptions): any; | ||
createContainers(options: any): any; | ||
updateContainers(options: any, updateOptions: any): void; | ||
createContainers(options: any): Container; | ||
createDefaultPreferences(): any[]; | ||
@@ -49,0 +43,0 @@ readonly beforewares: any[]; |
@@ -113,5 +113,3 @@ module.exports = | ||
this.createServiceFunc = combine(arguments, arg => arg.createServiceFunc); | ||
this.preCreateServiceFunc = combine(arguments, arg => arg.preCreateServiceFunc); | ||
this.createContainerFunc = combine(arguments, arg => arg.createContainerFunc); | ||
this.updateContainerFunc = combine(arguments, arg => arg.updateContainerFunc); | ||
this.beforeware = combine(arguments, arg => arg.beforeware); | ||
@@ -129,18 +127,12 @@ this.middleware = combine(arguments, arg => arg.middleware); | ||
} | ||
createServiceContext(options, updateOptions) { | ||
this.createService(options, updateOptions); | ||
createServiceContext(options) { | ||
const services = this.createService(options); | ||
return async (req, connectionParams, webSocket) => { | ||
const results = await Promise.all(this.createContextFunc.map(createContext => createContext(req, connectionParams, webSocket))); | ||
return lodash_1.merge({}, ...results, Object.assign({}, this.services)); | ||
return lodash_1.merge({}, ...results, Object.assign({}, services)); | ||
}; | ||
} | ||
async createService(options, updateOptions) { | ||
if (this.container) { | ||
this.updateContainers(options, updateOptions); | ||
} | ||
else { | ||
this.createContainers(options); | ||
await Promise.all(this.preCreateServiceFunc.map(async (createService) => await createService(this.container))); | ||
} | ||
return this.services = lodash_1.merge({}, ...this.createServiceFunc.map(createService => createService(this.container))); | ||
createService(options) { | ||
const container = this.createContainers(options); | ||
return lodash_1.merge({}, ...this.createServiceFunc.map(createService => createService(container))); | ||
} | ||
@@ -154,18 +146,6 @@ createResolvers(options) { | ||
createContainers(options) { | ||
this.container = new inversify_1.Container(); | ||
this.createContainerFunc.map(createModule => this.container.load(createModule(options))); | ||
this.container.bind('IDefaultSettings').toConstantValue(this.getPreferences()); | ||
return this.container; | ||
const container = new inversify_1.Container(); | ||
this.createContainerFunc.map(createModule => container.load(createModule(options))); | ||
return container; | ||
} | ||
updateContainers(options, updateOptions) { | ||
let mergedModules = lodash_1.merge({}, ...this.updateContainerFunc); | ||
const matchingModules = []; | ||
updateOptions.forEach(option => { | ||
const searchModule = mergedModules[option]; | ||
if (searchModule) { | ||
matchingModules.push(searchModule); | ||
} | ||
}); | ||
matchingModules.map(createModule => this.container.load(createModule(options))); | ||
} | ||
createDefaultPreferences() { | ||
@@ -172,0 +152,0 @@ return utils_1.transformPrefsToArray(lodash_1.merge(...this.createPreference)); |
{ | ||
"name": "@common-stack/server-core", | ||
"version": "0.0.152-0", | ||
"version": "0.0.152", | ||
"description": "xterm server services for Node", | ||
@@ -51,3 +51,3 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@common-stack/utils": "^0.0.152-0", | ||
"@common-stack/utils": "^0.0.152", | ||
"cross-env": "^5.1.3", | ||
@@ -59,3 +59,3 @@ "jest": "^22.4.2", | ||
"dependencies": { | ||
"@common-stack/core": "^0.0.152-0" | ||
"@common-stack/core": "^0.0.152" | ||
}, | ||
@@ -62,0 +62,0 @@ "typings": "lib/index.d.ts", |
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
34982
409
Updated@common-stack/core@^0.0.152