| 422 | } |
| 423 | |
| 424 | private matchUrlPattern(path: string, routeType: UrlPatterns): Match | undefined { |
| 425 | const pattern = this.urlPatternMap[routeType]; |
| 426 | if (!pattern) { |
| 427 | throw new InvalidValueError(`Unknown route type: ${routeType}`); |
| 428 | } |
| 429 | |
| 430 | const match = pattern.match(path); |
| 431 | if (!match) { |
| 432 | return; |
| 433 | } |
| 434 | |
| 435 | if (match.type in this.modelNameMapping) { |
| 436 | throw new InvalidValueError( |
| 437 | `use the mapped model name: ${this.modelNameMapping[match.type]} and not ${match.type}`, |
| 438 | ); |
| 439 | } |
| 440 | |
| 441 | if (match.type in this.reverseModelNameMapping) { |
| 442 | match.type = this.reverseModelNameMapping[match.type]; |
| 443 | } |
| 444 | |
| 445 | return match; |
| 446 | } |
| 447 | |
| 448 | async handleRequest({ client, method, path, query, requestBody }: RequestContext<Schema>): Promise<Response> { |
| 449 | method = method.toUpperCase(); |