@lodestar/api
Version:
A Typescript REST client for the Ethereum Consensus API
19 lines • 804 B
JavaScript
import { mapValues } from "@lodestar/utils";
import { getFastifySchema } from "../schema.js";
import { toColonNotationPath } from "../urlFormat.js";
import { createFastifyHandler } from "./handler.js";
export function createFastifyRoute(definition, method, operationId) {
return {
url: toColonNotationPath(definition.url),
method: definition.method,
handler: createFastifyHandler(definition, method, operationId),
schema: {
...getFastifySchema(definition.req.schema),
operationId,
},
};
}
export function createFastifyRoutes(definitions, methods) {
return mapValues(definitions, (definition, operationId) => createFastifyRoute(definition, methods?.[operationId]?.bind(methods), operationId));
}
//# sourceMappingURL=route.js.map