
REST API with Node.js: Building a Secure Task Management API
As part of my internship at Valentius Kryptix, I worked on a project focused on building a REST API using Node.js. The objective of the project was to understand how backend applications communicate with clients through APIs and how authentication, database operations, validation, and security can be implemented in a practical application.
For this project, I developed a Task Management REST API using Node.js, Express.js, SQLite, JWT, and bcrypt. The API allows users to register and log in securely and provides authenticated users with the ability to create, view, update, and delete their tasks.
Project Overview
The main resource of the application is a task. Each task contains information such as a title, description, and status. The API follows REST principles and uses standard HTTP methods such as GET, POST, PUT, and DELETE for different operations.
The project includes user registration and login functionality. During registration, the user’s password is not stored directly in the database. Instead, it is hashed using bcrypt before being stored. This is an important security practice because sensitive passwords should never be stored as plain text.
After successful login, the API generates a JSON Web Token (JWT). This token is required when accessing protected task-management endpoints. The authentication middleware verifies the token before allowing a user to perform operations on their tasks.
CRUD Operations
One of the main objectives of this project was implementing complete CRUD functionality.
Create: Users can create new tasks using the POST method.
Read: Users can retrieve all their tasks or request a specific task using GET.
Update: Existing tasks can be modified using PUT.
Delete: Tasks can be removed using DELETE.
The API also ensures that users can only access their own tasks. This provides an additional layer of authorization and prevents users from accessing another user’s data.
Key Learnings
The first important learning from this project was JWT-based authentication. I learned how tokens can be generated after login and verified through authentication middleware before allowing access to protected API routes.
The second learning was secure password handling. Using bcrypt helped me understand why passwords should never be stored as plain text and how password hashing can improve application security.
Another important learning was API validation and HTTP status codes. I implemented validation for incoming data and used appropriate responses such as 201 Created for successful resource creation, 200 OK for successful operations, 400 Bad Request for invalid input, 401 Unauthorized for authentication problems, and 404 Not Found when a requested resource does not exist.
Testing the API
I tested the API using Postman. I verified user registration, login, JWT authentication, task creation, task retrieval, task updates, and task deletion. I also tested protected routes without authentication to confirm that unauthorized requests were rejected correctly.
Testing each endpoint individually helped me understand how a frontend application would communicate with a backend API in a real-world application.
Conclusion
Building this Task Management REST API gave me practical experience with backend development and helped me understand the complete flow from authentication to database operations and API testing.
This project strengthened my understanding of Node.js, Express.js, REST APIs, JWT authentication, SQLite, password hashing, validation, and Postman testing. It also gave me a better understanding of how backend services are structured and how secure and reliable APIs can be developed.
Project Repository:
https://github.com/mohan5535/Task-Management-API


Leave a Reply
You must be logged in to post a comment.