UNPKG

astroboy

Version:

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

27 lines 1.02 kB
"use strict"; const fs = require("fs"); const Loader_1 = require("../core/Loader"); class AstroboyServiceLoader extends Loader_1.Loader { async load() { let services = {}; for (const item of this.dirs) { const indexFile = `${item.baseDir}/app/services/index.js`; if (fs.existsSync(indexFile)) { services[item.name] = require(indexFile); } else { const entries = await this.globDir(item.baseDir, this.config.pattern || []); if (entries.length > 0) { services[item.name] = {}; entries.forEach(entry => { const key = this.resolveExtensions(entry.split('services/')[1], true); services[item.name][key] = require(entry); }); } } } this.app.services = services; } } module.exports = AstroboyServiceLoader; //# sourceMappingURL=AstroboyServiceLoader.js.map