A simple Express.js backend project that demonstrates different HTTP status codes with clear examples.
This project helps in understanding how HTTP status codes work in real APIs.
It focuses on:
- returning proper HTTP status codes
- structuring backend with controllers and routes
- building a clean Express.js API
- testing APIs using REST Client
- Node.js
- Express.js
- Nodemon
express-project-10-status-code-demo-api
│
├─ src
│ ├─ controllers
│ │ └─ statusCode.controller.js
│ │
│ └─ routes
│ └─ statusCode.route.js
│
├─ index.js
├─ api-test.rest
├─ .gitignore
├─ package.json
└─ README.md
Clone the repository
git clone https://github.com/a2rp/express-project-10-status-code-demo-api.git
cd express-project-10-status-code-demo-apiInstall dependencies
npm installDevelopment mode (with nodemon)
npm run devProduction mode
npm startServer runs at:
http://localhost:1198
GET /
GET /status/200
GET /status/201
GET /status/400
GET /status/401
GET /status/404
GET /status/500
{
"success": true,
"statusCode": 200,
"message": "OK - Request completed successfully"
}By building this project, you learn:
- what HTTP status codes mean
- when to use different status codes
- how to structure Express backend
- how to separate routes and controllers
- how to test APIs
Ashish Ranjan
Follow me
- GitHub: https://github.com/a2rp
- Portfolio: https://www.ashishranjan.net
- LinkedIn: https://www.linkedin.com/in/aashishranjan
- Facebook: https://www.facebook.com/theash.ashish/