Building Blog APIs with Node.js Express and JWT: Mini Project Session 35 (Updated May 2026)
Building a real backend project is the single fastest way to go from "I've watched the tutorials" to "I'm ready to interview." The Blog APIs mini project in session 35 of our Full Stack series combines Node.js, Express, MVC architecture, JWT authentication, authorization middleware, and API security into a single working system. NASSCOM and Deloitte project demand for 1.25 million tech professionals in India by 2027 — and every Node.js developer job description lists REST API development, JWT security, and backend project experience as requirements. This is how you build that experience.
- Blog APIs mini project covers: user registration/login, JWT auth, post CRUD with authorization, and middleware
- MVC architecture keeps code organized — Models handle data, Controllers handle logic, Routes handle URLs
- JWT middleware protects routes — only authenticated users can create posts; only authors can edit their own
- Input validation with express-validator and error handling middleware make the API production-ready
- Completing this project gives you a real backend portfolio piece that interviewers can clone and run
What the Blog APIs Project Builds and Why It Matters for Interviews
The Blog APIs project simulates the backend of a real blogging platform — think the API layer behind a system like Medium or Dev.to. Users register with name, email, and password. They log in to receive a JWT token. Authenticated users can create blog posts, view all posts, edit their own posts, and delete their own posts. Admin users can moderate or delete any post. This covers every fundamental backend skill that Node.js developer job listings at TCS Digital, Infosys, KPIT, and product startups actually require: REST API design, JWT authentication, role-based authorization, database interaction, input validation, and structured error responses. What most students don't realize is that interviewers often ask you to explain a project you've built, not just solve a coding problem. A well-built Blog API project tells a clear story: I understand auth flows, I can structure code professionally, and I know how to secure an API.

Project Architecture: MVC Pattern with Node.js and Express
The project follows the MVC (Model-View-Controller) pattern that most professional Node.js teams use. The Models folder contains Mongoose schemas — User model with name, email, hashed password, and role fields; Post model with title, content, author (ref to User), and timestamps. The Controllers folder contains the business logic — userController.js handles registration and login; postController.js handles CRUD operations. The Routes folder maps HTTP verbs and URLs to controller functions — POST /api/auth/register, POST /api/auth/login, GET /api/posts, POST /api/posts (protected), PUT /api/posts/:id (protected + owner check), DELETE /api/posts/:id (protected + owner or admin). Middleware sits between routes and controllers — the auth middleware validates JWT tokens; the role middleware checks if the user is an admin. This structure keeps the codebase clean and mirrors what you'd find in a real professional Node.js API at any mid-to-large company.
Blog APIs Project: Endpoint Reference
| Method | Endpoint | Auth Required | Description |
|---|---|---|---|
| POST | /api/auth/register | No | Register new user |
| POST | /api/auth/login | No | Login, returns JWT |
| GET | /api/posts | No | List all posts (paginated) |
| POST | /api/posts | Yes (JWT) | Create post |
| PUT | /api/posts/:id | Yes (owner) | Update own post |
| DELETE | /api/posts/:id | Yes (owner/admin) | Delete post |
User Authentication: Registration, Login, and JWT Token Generation
Authentication starts with registration: the user submits name, email, and password. The controller validates the input (no empty fields, valid email format, password minimum 8 characters), checks that the email isn't already registered, hashes the password using bcrypt with 12 salt rounds, and saves the new user document to MongoDB. Login is the reverse: validate input, find the user by email, compare the submitted password against the stored hash using bcrypt.compare(), and if valid, generate a JWT token signed with a secret key from your .env file. The token contains the user's id and role in its payload — no sensitive data. We set a 7-day expiry for this project. The token is returned to the client, which stores it and sends it as a Bearer token in the Authorization header on every subsequent protected request.

Authorization Middleware: Protecting Routes and Ownership Checks
Authorization is where the project gets interesting. The auth middleware (authMiddleware.js) extracts the Bearer token from the Authorization header, verifies it using jwt.verify() with the secret, attaches the decoded payload to req.user, and calls next(). If the token is missing or invalid, it returns a 401 Unauthorized response. The ownership check happens in the controller: before allowing an update or delete, the controller fetches the post and compares post.author.toString() === req.user.id. If they don't match AND the user isn't an admin, it returns 403 Forbidden. This two-layer security — authentication at the middleware level, authorization at the controller level — is the pattern used in production APIs at Persistent Systems, ThoughtWorks, and product companies. Understanding the difference between 401 (not authenticated) and 403 (not authorized) is a common interview question that trips up candidates who haven't built a real project.
Post CRUD APIs: Create, Read, Update, Delete with Proper Validation
The post CRUD endpoints follow RESTful conventions strictly. GET /api/posts returns a paginated list of posts with author name populated using Mongoose .populate(). GET /api/posts/:id returns a single post. POST /api/posts (protected) validates the request body — title required, minimum 10 characters; content required, minimum 50 characters — using express-validator middleware, then creates the post with author set to req.user.id. PUT /api/posts/:id (protected + owner check) allows partial updates — only send the fields you want to change, and the controller uses $set to update only those fields. DELETE /api/posts/:id (protected + owner or admin) permanently removes the post and returns 204 No Content. All endpoints return consistent JSON responses with a success flag and meaningful error messages — this consistency is what separates a portfolio project from production-grade code and is specifically what senior interviewers at Zensar and Capgemini look for.
Error Handling, Testing, and Getting Interview-Ready with This Project
Making the project interview-ready requires three final steps. First, global error handling: a central errorHandler.js middleware catches errors thrown by any controller and returns a structured JSON response with statusCode and message. This means your controllers can throw errors without worrying about the response format. Second, input validation: express-validator chains on each route ensure you never hit the database with invalid data. Third, testing: use Thunder Client (VS Code extension) or Postman to test every endpoint — register a user, log in to get a token, create a post, try to edit another user's post and confirm you get 403, delete your own post and confirm 204. Screenshot or export these test results — showing them in an interview signals you take quality seriously. At ABC Trainings, we walk through the entire project in our Full Stack Development course at Wagholi, Hadapsar, Cidco, Osmanpura, and Sangli centers.
CMYKPY Scholarship for Full Stack Development
The Maharashtra CMYKPY scheme pays ₹6,000–₹10,000/month to eligible trainees during the Full Stack Development course. PMKVY 4.0 has trained 2.1 crore youth nationally — our NSDC-affiliated programs qualify. Requirements: Maharashtra resident, age 18-35, 10th pass. WhatsApp 7774002496 to check your eligibility before the next batch at Wagholi, Hadapsar, or Sangli.
Get the Full Stack Development Brochure + Fees + Batch Dates on WhatsApp
Free 1:1 counselling. Placement track record. CMYKPY/PMKVY eligibility check.
💬 Get Brochure on WhatsApp📞 Call 7039169629About the author: Rahul Patil. 12 yrs experience training engineers across Maharashtra.
Visit Our Centers
- Wagholi (Pune): 1st Floor, Laxmi Datta Arcade, Pune-Ahilyanagar Highway. Call 7039169629
- Hadapsar (Pune HQ): 1st Floor, Shree Tower, opp. Vaibhav Theater, Magarpatta. Call 7039169629
- Cidco (Chh. Sambhajinagar): Kalpana Plaza, opp. Eiffel Tower, N-1 Cidco. Call 7039169629
- Osmanpura (Chh. Sambhajinagar): S.S.C Board to Peer Bazar Road, near Jama Masjid. Call 7039169629
- Sangli: Shubham Emphoria, 1st Floor, Above US Polo Assn., Sangli-Miraj Rd, Vishrambag. Weekend batches available. Call 7039169629
FAQs
What does the Blog APIs mini project in Node.js cover?
The Blog APIs mini project covers: user registration and login with bcrypt password hashing, JWT token generation and verification, MVC architecture with Mongoose models and Express controllers, protected routes with auth middleware, ownership-based authorization for edit and delete operations, input validation with express-validator, global error handling middleware, and RESTful API design with consistent JSON responses.
What is the difference between authentication and authorization in APIs?
Authentication verifies who you are — the server checks your credentials (email + password) and issues a JWT token as proof. Authorization decides what you are allowed to do — the server checks your token's payload (user id, role) against the resource being accessed. In the Blog API: login is authentication; checking that only the post author can edit their own post is authorization.
Will building the Blog APIs project help me get a Node.js job in Pune?
Yes — significantly. Node.js developer interviews at TCS Digital, KPIT, Persistent Systems, and startups typically include a project discussion and sometimes a take-home task very similar to the Blog API. Having a working, well-structured project on GitHub that you can explain end-to-end — auth flow, middleware chain, database queries — separates you from candidates who only watched tutorials.
Does ABC Trainings Full Stack course include project-based learning?
Yes — ABC Trainings Full Stack Development program is project-based throughout. Beyond the Blog APIs, students build a complete e-commerce backend, a weather app using REST APIs, and a React frontend connected to their own Express backend. All projects are portfolio-ready and available on GitHub. Course available at Wagholi, Hadapsar, Cidco, Osmanpura, and Sangli.




