import 'reflect-metadata'; import { actionConfigStore } from '../action/store'; export interface HandlerConfig { type: 'set-cookies-http-handler'; } export function handler(cfg: HandlerConfig) { return (target: any, key: string, descriptor: PropertyDescriptor) => { const { type } = cfg; const ac = actionConfigStore.get(target); if (typeof target !== 'function') { throw new Error('Only use @handler with a static method.'); } if (ac.handlers[type]) { throw new Error(`A ${type} handler has already been assigned as ${ac.handlers[type]}.`); } ac.handlers[type] = key; }; }