astroboy
Version:
Astroboy(阿童木)is a Nodejs SFB(Separation of Front and Back ends) framework, built on koa2.
30 lines • 1.08 kB
JavaScript
;
const lodash = require("lodash");
const Loader_1 = require("../core/Loader");
class AstroboyFnLoader extends Loader_1.Loader {
load() {
// 加载 Fn 配置
let fnConfig = {};
this.globDirs(this.config.configPattern || [], entries => {
entries.forEach(entry => {
fnConfig = lodash.merge(fnConfig, require(entry));
});
});
this.app.fnConfig = fnConfig;
let fns = {};
this.dirs.forEach(item => {
this.globDir(item.baseDir, this.config.pattern || [], entries => {
if (entries.length > 0) {
entries.forEach(entry => {
const key = this.resolveExtensions(entry.split('fns/')[1], true);
const config = fnConfig[key] || {};
fns[key] = require(entry)(config.options || {});
});
}
});
});
this.app.fns = fns;
}
}
module.exports = AstroboyFnLoader;
//# sourceMappingURL=AstroboyFnLoader.js.map