UNPKG

@noodletired/rest-ts-core

Version:

Type-safe rest API definitions to share

25 lines (24 loc) 919 B
import { EndpointDefinition } from '../types'; /** * Creates a string representing the generic path for the given endpoint. * * Path parameters are prefixed with a colon ':'. * * For instance, for an endpoint defined with: "GET `/pets/${type}/${name}`", * this method returns "`/pets/:type/:name`". * * @param def The endpoint definition whose path to get */ export declare function buildGenericPathname(def: EndpointDefinition): string; /** * Builds the pathname given an endpoint definition and some path parameters. * * For instance, `buildPathnameFromParams(GET '/pets/${type}/${name}', {type: "cat", name: "linus"})` * returns: "/pets/cat/linus". * * @param def The definition whose pathname to build * @param params The path parameters to inject */ export declare function buildPathnameFromParams<T extends EndpointDefinition>(def: T, params: { [key: string]: string; } | undefined): string;