import { MapperDescriptor, RestfulResponse, ControllerOption, RequestHandlerStore } from "./index.dto.js"; export const requestHandlerStorage = new Map>(); export function Controller(command: string, option: ControllerOption = {}) { return function(target: any, propertykey: string, descriptor: MapperDescriptor) { const handler = descriptor.value; if (requestHandlerStorage.has(command)) { throw new Error(`Duplicate request handler for ${command}`); } if (handler) { requestHandlerStorage.set(command, { handler, option }); } return descriptor; } }