The Task Manager API is a Node.js application that allows users to manage their tasks programmatically. It provides RESTful endpoints for creating, reading, updating, and deleting tasks.
- Create tasks with a title, description, due date, and completion status.
- View all tasks or specific tasks by ID.
- Update task details or mark them as complete.
- Delete tasks when they are no longer needed.
To run this project locally, ensure you have the following installed:
git clone https://github.com/M-Tayyab06/Node-Js-APP.git
cd Node-Js-APPnpm installStart the server locally:
npm startThe API will be available at http://localhost:3000.
http://localhost:3000/api
GET /tasks
- Description: Retrieve a list of all tasks.
- Response:
[ { "id": 1, "title": "Learn Node.js", "description": "Study REST APIs and Express.js", "dueDate": "2025-01-20", "completed": false } ]
GET /tasks/:id
- Description: Retrieve details of a specific task by ID.
- Response:
{ "id": 1, "title": "Learn Node.js", "description": "Study REST APIs and Express.js", "dueDate": "2025-01-20", "completed": false }
POST /tasks
- Description: Add a new task.
- Body (JSON):
{ "title": "Write documentation", "description": "Prepare the project README", "dueDate": "2025-01-22" } - Response:
{ "id": 2, "title": "Write documentation", "description": "Prepare the project README", "dueDate": "2025-01-22", "completed": false }
PUT /tasks/:id
- Description: Update a task’s details.
- Body (JSON):
{ "title": "Write documentation (Updated)", "completed": true } - Response:
{ "id": 2, "title": "Write documentation (Updated)", "description": "Prepare the project README", "dueDate": "2025-01-22", "completed": true }
DELETE /tasks/:id
- Description: Remove a task by ID.
- Response: Status
204 No Content.
The project includes a Dockerfile for containerization:
# Use Node.js LTS as the base image
FROM node:16
# Set the working directory in the container
WORKDIR /app
# Copy package files and install dependencies
COPY package*.json ./
RUN npm install
# Copy the application code
COPY . .
# Expose the port the app runs on
EXPOSE 3000
# Start the application
CMD ["npm", "start"]-
Build the Docker image:
docker build -t task-manager-api . -
Run the container:
docker run -p 3000:3000 task-manager-api
Use Postman or cURL to interact with the API. See the "API Endpoints" section for details.