UNPKG

@lodestar/api

Version:

A Typescript REST client for the Ethereum Consensus API

31 lines 1.05 kB
export declare enum TokenType { String = "String", Variable = "Variable" } export type Token = { type: TokenType.String; str: string; } | { type: TokenType.Variable; var: string; }; type Args = Record<string, string | number>; export declare function urlToTokens(path: string): Token[]; /** * Compile a route URL formatter with syntax `/path/{var1}/{var2}`. * Returns a function that expects an object `{var1: 1, var2: 2}`, and returns`/path/1/2`. * * It's cheap enough to be negligible. For the sample input below it costs: * - compile: 1010 ns / op * - execute: 105 ns / op * - execute with template literal: 12 ns / op * @param path `/eth/v1/validator/:name/attester/:epoch` */ export declare function compileRouteUrlFormatter(path: string): (arg: Args) => string; /** * Converts notation used in OpenAPI spec '/states/{state_id}', * into colon notation used by fastify '/states/:state_id' */ export declare function toColonNotationPath(path: string): string; export {}; //# sourceMappingURL=urlFormat.d.ts.map