UNPKG

astroboy

Version:

Astroboy(阿童木)is a Nodejs SFB(Separation of Front and Back ends) framework, built on koa2.

28 lines 1.04 kB
"use strict"; const lodash = require("lodash"); const Loader_1 = require("../core/Loader"); class AstroboyFnLoader extends Loader_1.Loader { async load() { // 加载 Fn 配置 let fnConfig = {}; const entries = await this.globDirs(this.config.configPattern || []); entries.forEach(entry => { fnConfig = lodash.merge(fnConfig, require(entry)); }); this.app.fnConfig = fnConfig; let fns = {}; for (const item of this.dirs) { const entries = await this.globDir(item.baseDir, this.config.pattern || []); 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