I am trying to add a new /health endpoint to my implementation of the cube js backend and i was wondering if there is a preferred method of doing that?
@hemanthsj Hey Hemanth! You can do so using express: https://cube.dev/docs/deployment#express but I believe we should provide this route as part of API. Let's track it's implementation in this issue.
@hemanthsj if the healthcheck endpoint is the only thing you need to customize about the server itself, you don't have to implement a whole express server and attach CubejsServerCore. CubejsServer.listen() resolves a reference to app which is the express app. You can use it to add an extra endpoint.
I'm doing effectively this:
const CubejsServer = require('@cubejs-backend/server');
const server = new CubejsServer();
server.listen().then(({ app, port }) => {
app.get('/ready', (req, res) => res.status(200).send('Healthy'));
console.log(`馃殌 Cube.js server is listening on ${port}`);
});
Thank you @willhausman
Most helpful comment
@hemanthsj if the healthcheck endpoint is the only thing you need to customize about the server itself, you don't have to implement a whole express server and attach
CubejsServerCore.CubejsServer.listen()resolves a reference toappwhich is the express app. You can use it to add an extra endpoint.I'm doing effectively this: