-
-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
63 changed files
with
282 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/api/src/client/beacon.ts → packages/api/src/beacon/client/beacon.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/api/src/client/config.ts → packages/api/src/beacon/client/config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/api/src/client/debug.ts → packages/api/src/beacon/client/debug.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/api/src/client/events.ts → packages/api/src/beacon/client/events.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
packages/api/src/client/index.ts → packages/api/src/beacon/client/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/api/src/client/lightclient.ts → ...ages/api/src/beacon/client/lightclient.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/api/src/client/lodestar.ts → packages/api/src/beacon/client/lodestar.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/api/src/client/node.ts → packages/api/src/beacon/client/node.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/api/src/client/validator.ts → packages/api/src/beacon/client/validator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import {Api as BeaconApi} from "./routes/beacon/index.js"; | ||
import {Api as ConfigApi} from "./routes/config.js"; | ||
import {Api as DebugApi} from "./routes/debug.js"; | ||
import {Api as EventsApi} from "./routes/events.js"; | ||
import {Api as LightclientApi} from "./routes/lightclient.js"; | ||
import {Api as LodestarApi} from "./routes/lodestar.js"; | ||
import {Api as NodeApi} from "./routes/node.js"; | ||
import {Api as ValidatorApi} from "./routes/validator.js"; | ||
|
||
// NOTE: Don't export server here so it's not bundled to all consumers | ||
|
||
export * as routes from "./routes/index.js"; | ||
export {getClient} from "./client/index.js"; | ||
|
||
export type Api = { | ||
beacon: BeaconApi; | ||
config: ConfigApi; | ||
debug: DebugApi; | ||
events: EventsApi; | ||
lightclient: LightclientApi; | ||
lodestar: LodestarApi; | ||
node: NodeApi; | ||
validator: ValidatorApi; | ||
}; | ||
|
||
// Declare namespaces for CLI options | ||
export type ApiNamespace = keyof Api; | ||
const allNamespacesObj: {[K in keyof Api]: true} = { | ||
beacon: true, | ||
config: true, | ||
debug: true, | ||
events: true, | ||
lightclient: true, | ||
lodestar: true, | ||
node: true, | ||
validator: true, | ||
}; | ||
export const allNamespaces = Object.keys(allNamespacesObj) as ApiNamespace[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/api/src/routes/beacon/index.ts → ...ges/api/src/beacon/routes/beacon/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/api/src/routes/events.ts → packages/api/src/beacon/routes/events.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/api/src/server/beacon.ts → packages/api/src/beacon/server/beacon.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/api/src/server/config.ts → packages/api/src/beacon/server/config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/api/src/server/debug.ts → packages/api/src/beacon/server/debug.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/api/src/server/events.ts → packages/api/src/beacon/server/events.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/api/src/server/lightclient.ts → ...ages/api/src/beacon/server/lightclient.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/api/src/server/lodestar.ts → packages/api/src/beacon/server/lodestar.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/api/src/server/node.ts → packages/api/src/beacon/server/node.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/api/src/server/validator.ts → packages/api/src/beacon/server/validator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {IChainForkConfig} from "@chainsafe/lodestar-config"; | ||
import {IHttpClient, generateGenericJsonClient} from "../utils/client/index.js"; | ||
import {Api, ReqTypes, routesData, getReqSerializers, getReturnTypes} from "./routes.js"; | ||
|
||
/** | ||
* REST HTTP client for builder routes | ||
*/ | ||
export function getClient(_config: IChainForkConfig, httpClient: IHttpClient): Api { | ||
const reqSerializers = getReqSerializers(); | ||
const returnTypes = getReturnTypes(); | ||
// All routes return JSON, use a client auto-generator | ||
return generateGenericJsonClient<Api, ReqTypes>(routesData, reqSerializers, returnTypes, httpClient); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {IChainForkConfig} from "@chainsafe/lodestar-config"; | ||
import {HttpClient, HttpClientModules, HttpClientOptions, IHttpClient} from "../utils/client/httpClient.js"; | ||
import {Api} from "./routes.js"; | ||
import * as builder from "./client.js"; | ||
|
||
// NOTE: Don't export server here so it's not bundled to all consumers | ||
|
||
export {Api}; | ||
|
||
// Note: build API does not have namespaces as routes are declared at the "root" namespace | ||
|
||
type ClientModules = HttpClientModules & { | ||
config: IChainForkConfig; | ||
httpClient?: IHttpClient; | ||
}; | ||
|
||
export function getClient(opts: HttpClientOptions, modules: ClientModules): Api { | ||
const {config} = modules; | ||
const httpClient = modules.httpClient ?? new HttpClient(opts, modules); | ||
|
||
return builder.getClient(config, httpClient); | ||
} |
Oops, something went wrong.