Files
lodestar/packages/api/src/client/node.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

14 lines
598 B
TypeScript

import {IBeaconConfig} from "@chainsafe/lodestar-config";
import {IHttpClient, generateGenericJsonClient} from "./utils";
import {Api, ReqTypes, routesData, getReqSerializers, getReturnTypes} from "../routes/node";
/**
* REST HTTP client for beacon routes
*/
export function getClient(config: IBeaconConfig, httpClient: IHttpClient): Api {
const reqSerializers = getReqSerializers();
const returnTypes = getReturnTypes(config);
// All routes return JSON, use a client auto-generator
return generateGenericJsonClient<Api, ReqTypes>(routesData, reqSerializers, returnTypes, httpClient);
}