UNPKG

gypsum

Version:

Simple and easy lightweight typescript server side framework on Node.js.

25 lines 827 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const string_1 = require("tools-box/string"); function HOOK(options = { private: false }) { return function (target, key, descriptor) { let hookName = string_1.capitalizeFirst(key); function hook(ctx, ...args) { args.push(ctx); this[key](...args) .then(() => { ctx.next(); }) .catch((error) => ctx.next(error)); } hook.__name = hookName; hook.isHook = true; hook.private = options.private; Object.defineProperty(target.constructor.prototype, hookName, { value: hook, enumerable: true }); }; } exports.HOOK = HOOK; //# sourceMappingURL=hook.js.map