Files
lodestar/packages/api/src/routes/lodestar.ts
Lion - dapplion de1e1210b4 Separate lodestar-api package (#2568)
* Refactor REST API definitions

* Simplify REST testing

* Bump to fastify 3.x.x

* Return {} in fastify handler to trigger send

* Move REST server to lodestar-api

* Improve REST tests

* Add eventstream test

* Clean up

* Bump versions

* Fix query string format

* Add extra debug routes

* Consume lodestar-api package

* Fix tests

* Revert package.json change

* Add HttpClient test

* Destroy all active requests immediately on close

* Fastify hook handlers must resolve

* Fix fastify hook config args

* Fix parsing of ValidatorId

* Remove e2e script test

* Add docs

* Simplify req declarations

* Review PR

* Update license
2021-05-27 12:17:49 -05:00

49 lines
1.5 KiB
TypeScript

import {Epoch} from "@chainsafe/lodestar-types";
import {mapValues} from "@chainsafe/lodestar-utils";
import {jsonType, ReqEmpty, reqEmpty, ReturnTypes, ReqSerializers, RoutesData, sameType} from "../utils";
// See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes
export type SyncChainDebugState = {
targetRoot: string | null;
targetSlot: number | null;
syncType: string;
status: string;
startEpoch: number;
peers: number;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
batches: any[];
};
export type Api = {
/** TODO: description */
getWtfNode(): Promise<{data: string}>;
/** TODO: description */
getLatestWeakSubjectivityCheckpointEpoch(): Promise<{data: Epoch}>;
/** TODO: description */
getSyncChainsDebugState(): Promise<{data: SyncChainDebugState[]}>;
};
/**
* Define javascript values for each route
*/
export const routesData: RoutesData<Api> = {
getWtfNode: {url: "/eth/v1/lodestar/wtfnode/", method: "GET"},
getLatestWeakSubjectivityCheckpointEpoch: {url: "/eth/v1/lodestar/ws_epoch/", method: "GET"},
getSyncChainsDebugState: {url: "/eth/v1/lodestar/sync-chains-debug-state", method: "GET"},
};
export type ReqTypes = {[K in keyof Api]: ReqEmpty};
export function getReqSerializers(): ReqSerializers<Api, ReqTypes> {
return mapValues(routesData, () => reqEmpty);
}
export function getReturnTypes(): ReturnTypes<Api> {
return {
getWtfNode: sameType(),
getLatestWeakSubjectivityCheckpointEpoch: sameType(),
getSyncChainsDebugState: jsonType(),
};
}