-
-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add syncing_status query parameter to eth/v1/node/health
- Loading branch information
Showing
7 changed files
with
110 additions
and
43 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
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 |
---|---|---|
@@ -1,32 +1,9 @@ | ||
import {ChainForkConfig} from "@lodestar/config"; | ||
import {Api, ReqTypes, routesData, getReturnTypes, getReqSerializers} from "../routes/node.js"; | ||
import {ServerRoutes, getGenericJsonServer} from "../../utils/server/index.js"; | ||
import {HttpStatusCode} from "../../utils/client/httpStatusCode.js"; | ||
import {ServerApi} from "../../interfaces.js"; | ||
|
||
export function getRoutes(config: ChainForkConfig, api: ServerApi<Api>): ServerRoutes<ServerApi<Api>, ReqTypes> { | ||
// All routes return JSON, use a server auto-generator | ||
const serverRoutes = getGenericJsonServer<ServerApi<Api>, ReqTypes>( | ||
{routesData, getReturnTypes, getReqSerializers}, | ||
config, | ||
api | ||
); | ||
|
||
return { | ||
...serverRoutes, | ||
|
||
getHealth: { | ||
...serverRoutes.getHealth, | ||
handler: async (req, res) => { | ||
try { | ||
await api.getHealth(); | ||
res.raw.writeHead(HttpStatusCode.OK); | ||
res.raw.end(); | ||
} catch (e) { | ||
res.raw.writeHead(HttpStatusCode.INTERNAL_SERVER_ERROR); | ||
res.raw.end(); | ||
} | ||
}, | ||
}, | ||
}; | ||
return getGenericJsonServer<ServerApi<Api>, ReqTypes>({routesData, getReturnTypes, getReqSerializers}, config, api); | ||
} |
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