@common-stack/server-core
Advanced tools
Comparing version 0.0.14-23 to 0.0.14-25
import { IResolverOptions, IDirectiveOptions } from '../interfaces'; | ||
import { Container } from 'inversify'; | ||
export declare const featureCatalog: any; | ||
@@ -9,2 +10,4 @@ export declare type FeatureParams = { | ||
createContextFunc?: Function | Function[]; | ||
createServiceFunc?: Function | Function[]; | ||
createContainerFunc?: Function | Function[]; | ||
beforeware?: any | any[]; | ||
@@ -20,2 +23,4 @@ middleware?: any | any[]; | ||
createContextFunc: Function[]; | ||
createServiceFunc: Function[]; | ||
createContainerFunc: Function[]; | ||
beforeware: Function[]; | ||
@@ -26,4 +31,7 @@ middleware: Function[]; | ||
createContext(req: any, connectionParams: any, webSocket?: 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): Container; | ||
readonly beforewares: any[]; | ||
@@ -30,0 +38,0 @@ readonly middlewares: any[]; |
@@ -78,3 +78,3 @@ module.exports = | ||
__export(__webpack_require__(1)); | ||
__export(__webpack_require__(4)); | ||
__export(__webpack_require__(5)); | ||
@@ -103,2 +103,3 @@ | ||
const lodash_1 = __webpack_require__(3); | ||
const inversify_1 = __webpack_require__(4); | ||
exports.featureCatalog = {}; | ||
@@ -108,2 +109,7 @@ const combine = (features, extractor) => lodash_1.without(lodash_1.union(...lodash_1.map(features, res => lodash_1.castArray(extractor(res)))), undefined); | ||
constructor(feature, ...features) { | ||
this.createServiceContext = (options) => async (req, connectionParams, webSocket) => { | ||
const services = this.createService(options); | ||
const results = await Promise.all(this.createContextFunc.map(createContext => createContext(req, connectionParams, webSocket))); | ||
return lodash_1.merge({}, ...results, Object.assign({}, services)); | ||
}; | ||
combine(arguments, arg => arg.catalogInfo).forEach(info => Object.keys(info).forEach(key => (exports.featureCatalog[key] = info[key]))); | ||
@@ -114,2 +120,4 @@ this.schema = combine(arguments, arg => arg.schema); | ||
this.createContextFunc = combine(arguments, arg => arg.createContextFunc); | ||
this.createServiceFunc = combine(arguments, arg => arg.createServiceFunc); | ||
this.createContainerFunc = combine(arguments, arg => arg.createContainerFunc); | ||
this.beforeware = combine(arguments, arg => arg.beforeware); | ||
@@ -125,2 +133,6 @@ this.middleware = combine(arguments, arg => arg.middleware); | ||
} | ||
createService(options) { | ||
const container = this.createContainers(options); | ||
return lodash_1.merge({}, ...this.createServiceFunc.map(createService => createService(container))); | ||
} | ||
createResolvers(options) { | ||
@@ -132,2 +144,7 @@ return lodash_1.merge({}, ...this.createResolversFunc.map(createResolvers => createResolvers(options))); | ||
} | ||
createContainers(options) { | ||
const container = new inversify_1.Container(); | ||
this.createContainerFunc.map(createModule => container.load(createModule(options))); | ||
return container; | ||
} | ||
get beforewares() { | ||
@@ -151,2 +168,8 @@ return this.beforeware; | ||
/* 4 */ | ||
/***/ (function(module, exports) { | ||
module.exports = require("inversify"); | ||
/***/ }), | ||
/* 5 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -160,7 +183,7 @@ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(__webpack_require__(5)); | ||
__export(__webpack_require__(6)); | ||
/***/ }), | ||
/* 5 */ | ||
/* 6 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -167,0 +190,0 @@ |
{ | ||
"name": "@common-stack/server-core", | ||
"version": "0.0.14-23", | ||
"version": "0.0.14-25", | ||
"description": "xterm server services for Node", | ||
@@ -51,3 +51,3 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@common-stack/utils": "^0.0.14-23", | ||
"@common-stack/utils": "^0.0.14-25", | ||
"cross-env": "^5.1.3", | ||
@@ -54,0 +54,0 @@ "jest": "^22.1.0", |
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
21455
19
234