opinionated-machine
Version:
Very opinionated DI framework for fastify, built on top of awilix
23 lines (22 loc) • 1.07 kB
TypeScript
/**
* Convert a Fastify-style path to the canonical OpenAPI/RFC 6570 form used
* by the manifest. The manifest emits OpenAPI-style paths so each generator
* can translate to its own dialect (Envoy regex matchers, KrakenD `{var}`,
* AWS `{proxy+}`).
*
* Supported Fastify shapes (find-my-way):
* - `:userId` ordinary parameter
* - `:userId?` optional parameter (the `?` is for matching only;
* we drop it from the path text)
* - `:userId(regex)` inline-constraint (the `(regex)` is for matching
* only; we drop it)
* - `*` wildcard → `{wildcard}`
*
* Examples:
* /users/:userId → /users/{userId}
* /users/:userId/posts/:id → /users/{userId}/posts/{id}
* /files/* → /files/{wildcard}
* /a/:id? → /a/{id}
* /items/:slug(\\w+) → /items/{slug}
*/
export declare function normalizePath(fastifyPath: string): string;