zents
Version:
ZenTS is a Node.js & TypeScript MVC-Framework for building rich web applications, released as free and open-source software under the MIT License. It is designed for building web applications with modern tools and design patterns.
28 lines • 1.13 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EntityLoader = void 0;
const AbstractZenFileLoader_1 = require("../filesystem/AbstractZenFileLoader");
const config_1 = require("../config/config");
const FS_1 = require("../filesystem/FS");
const logger_1 = require("../log/logger");
class EntityLoader extends AbstractZenFileLoader_1.AbstractZenFileLoader {
async load() {
var _a;
const entities = new Map();
if (!((_a = config_1.config.database) === null || _a === void 0 ? void 0 : _a.enable)) {
return entities;
}
const filePaths = await FS_1.fs.readDir(FS_1.fs.resolveZenPath('entity'), false);
for (const filePath of filePaths) {
const { key, module } = await this.loadModule(filePath);
if (entities.has(key)) {
logger_1.log.warn(`Entity with key "${key}" is already registered!`);
continue;
}
entities.set(key, module);
}
return entities;
}
}
exports.EntityLoader = EntityLoader;
//# sourceMappingURL=EntityLoader.js.map