@colucom/osseus
Advanced tools
Comparing version 2.1.0 to 2.2.0
58
index.js
@@ -36,27 +36,37 @@ const async = require('async') | ||
if (key.startsWith('osseus')) { | ||
let moduleName = key.substring(7) // 'osseus_' length | ||
let dependencies = osseus.config[key].dependencies || [] | ||
if (typeof dependencies === 'string') { | ||
dependencies = dependencies.split(',') | ||
let loadModule = typeof osseus.config[key].load !== 'undefined' ? osseus.config[key].load : true | ||
let isPrivate = typeof osseus.config[key].private !== 'undefined' ? osseus.config[key].private : false | ||
let scope = osseus.config[key].scope | ||
log(`${key} loadModule: ${loadModule}, isPrivate: ${isPrivate}, scope: ${scope}`) | ||
if (loadModule) { | ||
let moduleName = key.substring(7) // 'osseus_' length | ||
let dependencies = osseus.config[key].dependencies || [] | ||
if (typeof dependencies === 'string') { | ||
dependencies = dependencies.split(',') | ||
} | ||
log(`${key} dependencies: ${dependencies}`) | ||
modules[moduleName] = dependencies | ||
modules[moduleName].push(async () => { | ||
key = key.replace('_', '-') | ||
key = isPrivate ? key : (scope ? `@${scope}/${key}` : `@colucom/${key}`) | ||
log(`require(${key}).init()...`) | ||
try { | ||
const _module = await requireModule(key).init(osseus) | ||
log(`required: ${key}`) | ||
if (_module.start) { | ||
log(`${key}.start()...`) | ||
await _module.start() | ||
log(`started ${key}`) | ||
} | ||
osseus[moduleName] = _module | ||
return _module | ||
} catch (err) { | ||
console.error(`osseus init`, err.stack) | ||
reject(err) | ||
} | ||
}) | ||
} else { | ||
console.warn(`not loading ${key}...`) | ||
} | ||
log(`${key} dependencies: ${dependencies}`) | ||
modules[moduleName] = dependencies | ||
modules[moduleName].push(async () => { | ||
key = key.replace('_', '-') | ||
log(`require(${key}).init()...`) | ||
try { | ||
const _module = await requireModule(key).init(osseus) | ||
log(`required: ${key}`) | ||
if (_module.start) { | ||
log(`${key}.start()...`) | ||
await _module.start() | ||
log(`started ${key}`) | ||
} | ||
osseus[moduleName] = _module | ||
return _module | ||
} catch (err) { | ||
console.error(`osseus init`, err.stack) | ||
reject(err) | ||
} | ||
}) | ||
} | ||
@@ -63,0 +73,0 @@ }) |
{ | ||
"name": "@colucom/osseus", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Osseus modular web server", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -47,4 +47,27 @@ [![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard) | ||
#### Dependencies | ||
#### Special module configurations | ||
##### Load | ||
Osseus modules by default are loaded when they appear in the configuration. | ||
You can specify explicitly whether to load a module or not using the `OSSEUS_<MODULE-NAME>_LOAD` configuration param which can be `true` or `false` (boolean) | ||
##### Private | ||
You can write your own private osseus modules which you do not wish to publish to the public npm. | ||
In order to use them you will need to specify explicitly that they are private using the `OSSEUS_<MODULE-NAME>_PRIVATE` configuration param which can be `true` or `false` (boolean) | ||
##### Scope | ||
You can write your own osseus modules and publish to the public npm under your own scope/organization. | ||
In order to use them you will need to specify explicitly the scope of the module using the `OSSEUS_<MODULE-NAME>_SCOPE` configuration param. | ||
By default modules are loaded from the [`@colucom`](https://www.npmjs.com/settings/colucom/packages) organization. | ||
##### Dependencies | ||
Osseus modules by default are initialized parallely. | ||
@@ -54,3 +77,3 @@ | ||
Generally speaking, if you wish for one osseus module to initialize before another you'll have to add the following configuration param: `OSSEUS_MODULE-1_DEPENDENCIES: ['module-2']` | ||
Generally speaking, if you wish for one osseus module to initialize before another you'll have to add the following configuration param: `OSSEUS_<MODULE-NAME>_DEPENDENCIES: ['<other-module-name>']` | ||
@@ -57,0 +80,0 @@ For example, if we wish to have an [osseus-server](https://github.com/colucom/osseus-server) but make sure we have [osseus-logger](https://github.com/colucom/osseus-logger) before that we will add to our configuration: `OSSEUS_SERVER_DEPENDENCIES: ['logger']` |
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
11728
87
85