UNPKG

@tsed/common

Version:
40 lines 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UseBeforeEach = void 0; const core_1 = require("@tsed/core"); const useBefore_1 = require("./useBefore"); /** * Mounts the specified middleware function or functions at the specified path: the middleware function is executed when * the base of the requested path matches `path. * * ```typescript * @Controller('/') * @UseBeforeEach(Middleware1) // Called before each endpoint * export class Ctrl { * * @Get('/') * get() { } * } * * ``` * * @returns {Function} * @param args * @decorator * @operation */ function UseBeforeEach(...args) { return (...decoratorArgs) => { switch (core_1.decoratorTypeOf(decoratorArgs)) { case core_1.DecoratorTypes.METHOD: return useBefore_1.UseBefore(...args)(...decoratorArgs); case core_1.DecoratorTypes.CLASS: core_1.decorateMethodsOf(decoratorArgs[0], useBefore_1.UseBefore(...args)); break; default: throw new core_1.UnsupportedDecoratorType(UseBeforeEach, decoratorArgs); } }; } exports.UseBeforeEach = UseBeforeEach; //# sourceMappingURL=useBeforeEach.js.map