@nestia/core
Version:
Super-fast validation decorators of NestJS
58 lines • 2.85 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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DynamicModule = void 0;
const common_1 = require("@nestjs/common");
const load_controller_1 = require("./internal/load_controller");
/**
* Dynamic module.
*
* `DynamicModule` is a namespace wrapping a convenient function, which can load
* controller classes dynamically just by specifying their directory path.
*
* @author Jeongho Nam - https://github.com/samchon
*/
var DynamicModule;
(function (DynamicModule) {
/**
* Mount dynamic module.
*
* Constructs a module instance with directory path of controller classes.
*
* Every controller classes in the target directory would be dynamically
* mounted.
*
* @param path Path of controllers
* @param metadata Additional metadata except controllers
* @returns Module instance
*/
function mount(path_1) {
return __awaiter(this, arguments, void 0, function* (path, metadata = {}, isTsNode) {
// LOAD CONTROLLERS
const controllers = yield (0, load_controller_1.load_controllers)(path, isTsNode);
// RETURN WITH DECORATING
let NestiaModule = class NestiaModule {
};
NestiaModule = __decorate([
(0, common_1.Module)(Object.assign(Object.assign({}, metadata), { controllers }))
], NestiaModule);
return NestiaModule;
});
}
DynamicModule.mount = mount;
})(DynamicModule || (exports.DynamicModule = DynamicModule = {}));
//# sourceMappingURL=DynamicModule.js.map