import {assertUnreachable} from '@techniker-me/tools'; export enum HttpMethod { GET = 0, POST = 1, PUT = 2, DELETE = 3, PATCH = 4, OPTIONS = 5 } export type HttpMethodType = keyof typeof HttpMethod; export class HttpMethodMapping { public static convertHttpMethodTypeToHttpMethod(method: HttpMethodType): HttpMethod { switch (method) { case 'GET': return HttpMethod.GET; case 'POST': return HttpMethod.POST; case 'PUT': return HttpMethod.PUT; case 'DELETE': return HttpMethod.DELETE; case 'PATCH': return HttpMethod.PATCH; case 'OPTIONS': return HttpMethod.OPTIONS; default: assertUnreachable(method); } } public static convertHttpMethodToHttpMethodType(method: HttpMethod): HttpMethodType { switch (method) { case HttpMethod.GET: return 'GET'; case HttpMethod.POST: return 'POST'; case HttpMethod.PUT: return 'PUT'; case HttpMethod.DELETE: return 'DELETE'; case HttpMethod.PATCH: return 'PATCH'; case HttpMethod.OPTIONS: return 'OPTIONS'; default: assertUnreachable(method); } } }