UNPKG

@miracledevs/paradigm-express-webapi

Version:

An easy to use MVC WebApi implementation over Express.

21 lines 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Controller = void 0; const controller_type_collection_1 = require("./controller-type-collection"); const controller_type_1 = require("./controller-type"); const paradigm_web_di_1 = require("@miracledevs/paradigm-web-di"); const object_type_1 = require("@miracledevs/paradigm-web-di/object-type"); function Controller(descriptor) { if (!descriptor) throw new Error("The controller descriptor is mandatory."); return (controller) => { if (!controller) throw new Error('Can not decorate a null or undefined value as a controller.'); if (controller_type_collection_1.ControllerTypeCollection.globalInstance.contains(controller)) throw new Error(`The controller ${(0, object_type_1.getObjectTypeName)(controller)} is already registered.`); controller_type_collection_1.ControllerTypeCollection.globalInstance.register(new controller_type_1.ControllerType(controller, descriptor)); (0, paradigm_web_di_1.Injectable)({ lifeTime: paradigm_web_di_1.DependencyLifeTime.Scoped })(controller); }; } exports.Controller = Controller; //# sourceMappingURL=controller.js.map