@brewww/nestjs-plugin-module
Version:
<p align="center"> <a href="http://brewww.com/" target="_blank"><img src="https://github.com/BrewInteractive/nestjs-plugin-module/blob/main/Brew-Logo-Small.png?raw=true" width="300" alt="Brew Logo" /></a> </p>
46 lines • 2.19 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
var PluginService_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PluginService = void 0;
const common_1 = require("@nestjs/common");
const core_1 = require("@nestjs/core");
let PluginService = PluginService_1 = class PluginService {
constructor(pluginTypes, moduleRef) {
this.pluginTypes = pluginTypes;
this.moduleRef = moduleRef;
this.logger = new common_1.Logger(PluginService_1.name);
this.plugins = [];
}
async onModuleInit() {
for (const pluginType of this.pluginTypes) {
const plugin = this.moduleRef.get(pluginType);
try {
await plugin.load();
this.plugins.push(plugin);
this.logger.log(`${plugin.displayName} plugin is loaded.`);
}
catch (error) {
this.logger.warn(`${plugin.displayName} plugin can't be loaded.: ${error}`);
}
}
}
};
exports.PluginService = PluginService;
exports.PluginService = PluginService = PluginService_1 = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, common_1.Inject)('PLUGINTYPES')),
__metadata("design:paramtypes", [Array, core_1.ModuleRef])
], PluginService);
//# sourceMappingURL=plugin.service.js.map
;