Challenge - 5 Problems
Health Check Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate1:30remaining
What is the output of this simple health check endpoint?
Consider this Node.js Express health check endpoint. What response does the server send when a GET request is made to
/health?Node.js
import express from 'express'; const app = express(); app.get('/health', (req, res) => { res.status(200).json({ status: 'ok' }); }); // Assume server listens correctly
Attempts:
2 left
💡 Hint
Look at the response method used and the status code set.
✗ Incorrect
The endpoint sends a JSON response with status code 200 and body {"status":"ok"}.
📝 Syntax
intermediate1:30remaining
Which option causes a syntax error in this health check endpoint?
Identify which code snippet will cause a syntax error when defining a health check endpoint in Express.
Attempts:
2 left
💡 Hint
Look carefully at the brackets and parentheses in the JSON response.
✗ Incorrect
Option A has a mismatched parenthesis in json({ status: 'ok' ) causing a syntax error.
❓ state_output
advanced2:00remaining
What is the output when the health check endpoint uses async function but forgets to await?
Given this health check endpoint, what will the client receive when requesting
/health?Node.js
app.get('/health', async (req, res) => { const status = checkDatabase(); // async function returning a promise res.json({ dbStatus: status }); }); async function checkDatabase() { return 'connected'; }
Attempts:
2 left
💡 Hint
Remember what happens if you don't await a promise before sending it in JSON.
✗ Incorrect
The status variable is a Promise object because checkDatabase() is async and not awaited. Sending it directly serializes the Promise object, not its resolved value.
🔧 Debug
advanced2:00remaining
Why does this health check endpoint cause the server to hang?
Examine this health check endpoint code. Why does the server never respond to requests on
/health?Node.js
app.get('/health', (req, res) => { checkServiceStatus(); }); function checkServiceStatus() { // some async operation but no callback or promise handling setTimeout(() => { console.log('Service is up'); }, 1000); }
Attempts:
2 left
💡 Hint
Think about what the server must do to finish a request.
✗ Incorrect
The endpoint calls an async function but never sends a response. The client waits indefinitely.
🧠 Conceptual
expert1:30remaining
Which option best describes the purpose of a health check endpoint in a Node.js service?
Choose the most accurate description of why health check endpoints are used in backend services.
Attempts:
2 left
💡 Hint
Think about monitoring and uptime checks.
✗ Incorrect
Health check endpoints are lightweight URLs used by monitoring tools to confirm the service is alive and responsive.