0
0
Expressframework~30 mins

Health check endpoints in Express - Mini Project: Build & Apply

Choose your learning style9 modes available
Health check endpoints
📖 Scenario: You are building a simple web server using Express.js. You want to add endpoints that let users check if the server is running and healthy.
🎯 Goal: Create two health check endpoints: /health that returns a simple status message, and /ready that returns a readiness message.
📋 What You'll Learn
Create an Express app instance called app
Add a GET endpoint /health that responds with JSON { status: 'ok' }
Add a GET endpoint /ready that responds with JSON { ready: true }
Make the app listen on port 3000
💡 Why This Matters
🌍 Real World
Health check endpoints help monitoring systems know if your server is running and ready to handle requests.
💼 Career
Many backend jobs require setting up health checks for services to ensure reliability and uptime.
Progress0 / 4 steps
1
Set up Express app
Create a variable called express by requiring the 'express' module. Then create an Express app instance called app by calling express().
Express
Need a hint?

Use require('express') to import Express and then call it to create app.

2
Add /health endpoint
Add a GET endpoint /health to the app that sends a JSON response with { status: 'ok' }.
Express
Need a hint?

Use app.get('/health', (req, res) => { ... }) and inside send JSON with res.json({ status: 'ok' }).

3
Add /ready endpoint
Add a GET endpoint /ready to the app that sends a JSON response with { ready: true }.
Express
Need a hint?

Use app.get('/ready', (req, res) => { ... }) and inside send JSON with res.json({ ready: true }).

4
Start the server
Make the app listen on port 3000 using app.listen.
Express
Need a hint?

Use app.listen(3000) to start the server on port 3000.