Complete the code to create a basic health check route that responds with 'OK'.
app.get('/health', (req, res) => { res.status([1]).send('OK'); });
The HTTP status code 200 means the request was successful. For a health check, this indicates the server is running fine.
Complete the code to add a JSON response with a status message in the health check endpoint.
app.get('/health', (req, res) => { res.status(200).json({ status: [1] }); });
The health check should return a positive status like 'ok' to indicate the server is healthy.
Fix the error in the health check route to correctly send a JSON response.
app.get('/health', (req, res) => { res.send([1]); });
To send JSON, pass an object like { status: 'ok' } to res.send(). Sending a string like 'OK' sends plain text, not JSON.
Fill both blanks to create a health check endpoint that responds with status 200 and JSON { status: 'healthy' }.
app.get('/health', (req, res) => { res.status([1]).json({ status: [2] }); });
The status code 200 means success, and the JSON response should have status 'healthy' as requested.
Fill all three blanks to create a health check endpoint that responds with status 200, JSON { status: 'ok' }, and logs 'Health check passed' to the console.
app.get('/health', (req, res) => { console.log([1]); res.status([2]).json({ status: [3] }); });
Logging 'Health check passed' helps monitor the endpoint. The status code 200 and JSON { status: 'ok' } indicate success.