UNPKG

@nestjs/core

Version:

Nest - modern, fast, powerful node.js web framework (@core)

31 lines (30 loc) 969 B
import { RequestMethod } from '@nestjs/common'; export const REQUEST_METHOD_MAP = { [RequestMethod.GET]: 'get', [RequestMethod.POST]: 'post', [RequestMethod.PUT]: 'put', [RequestMethod.DELETE]: 'delete', [RequestMethod.PATCH]: 'patch', [RequestMethod.ALL]: 'all', [RequestMethod.OPTIONS]: 'options', [RequestMethod.HEAD]: 'head', [RequestMethod.SEARCH]: 'search', [RequestMethod.PROPFIND]: 'propfind', [RequestMethod.PROPPATCH]: 'proppatch', [RequestMethod.MKCOL]: 'mkcol', [RequestMethod.COPY]: 'copy', [RequestMethod.MOVE]: 'move', [RequestMethod.LOCK]: 'lock', [RequestMethod.UNLOCK]: 'unlock', [RequestMethod.QUERY]: 'query', }; export class RouterMethodFactory { get(target, requestMethod) { const methodName = REQUEST_METHOD_MAP[requestMethod]; const method = target[methodName]; if (!method) { return target.use; } return method; } }