@gabliam/web-core
Version:
Gabliam plugin for add web-core
49 lines (48 loc) • 1.59 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RestController = exports.Controller = void 0;
/* eslint-disable @typescript-eslint/no-redeclare */
const core_1 = require("@gabliam/core");
const constants_1 = require("../constants");
exports.Controller = (0, core_1.makeDecorator)(constants_1.METADATA_KEY.controller, (options) => {
let path;
let name;
if (typeof options === 'string') {
path = options;
}
else {
path = options.path;
if (options.name) {
name = options.name;
}
}
return { path, name, json: false };
}, (cls, annotationInstance) => {
let id = cls;
if (annotationInstance.name) {
id = annotationInstance.name;
}
(0, core_1.injectable)()(cls);
(0, core_1.Register)({ type: constants_1.TYPE.Controller, id })(cls);
}, true, constants_1.ERRORS_MSGS.DUPLICATED_CONTROLLER_DECORATOR);
exports.RestController = (0, core_1.makeDecorator)(constants_1.METADATA_KEY.controller, (options) => {
let path;
let name;
if (typeof options === 'string') {
path = options;
}
else {
path = options.path;
if (options.name) {
name = options.name;
}
}
return { path, name, json: true };
}, (cls, annotationInstance) => {
let id = cls;
if (annotationInstance.name) {
id = annotationInstance.name;
}
(0, core_1.injectable)()(cls);
(0, core_1.Register)({ type: constants_1.TYPE.Controller, id })(cls);
}, true, constants_1.ERRORS_MSGS.DUPLICATED_CONTROLLER_DECORATOR);