MCPcopy Create free account
hub / github.com/zenstackhq/zenstack / matchUrlPattern

Method matchUrlPattern

packages/server/src/api/rest/index.ts:424–446  ·  view source on GitHub ↗
(path: string, routeType: UrlPatterns)

Source from the content-addressed store, hash-verified

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();

Callers 1

handleRequestMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected