A progressive Node.js framework for building efficient and scalable server-side applications.
This repository contains a simple implementation of CRUD (Create, Read, Update, Delete) operations for managing users using NestJS. The API allows you to add, retrieve, update, and delete users with appropriate HTTP methods and status codes.
- Add User: Create a new user and store it in memory.
- Get All Users: Retrieve a list of all users.
- Get Single User: Retrieve a single user by their ID.
- Update User: Update an existing user's details by their ID.
- Delete User: Remove a user by their ID and return the remaining users.
-
Add User
- Method:
POST
- URL:
/users/v1/addUser
- Body (JSON):
{ "id": 1, "name": "John Doe", "email": "john@example.com" }
- Response:
{ "usersData": [...] }
- Method:
-
Get All Users
- Method:
GET
- URL:
/users/v1/getUsers
- Response:
{ "usersData": [...] }
- Method:
-
Get Single User
- Method:
GET
- URL:
/users/v1/getUser/:id
- Path Variable:
id
(e.g., 1) - Response:
{ "user": {...} }
- Method:
-
Update User
- Method:
PUT
- URL:
/users/v1/updateUser/:id
- Path Variable:
id
(e.g., 1) - Body (JSON):
{ "id": 1, "name": "John Smith", "email": "john.smith@example.com" }
- Response:
{ "user": {...} }
- Method:
-
Delete User
- Method:
DELETE
- URL:
/users/v1/deleteUser/:id
- Path Variable:
id
(e.g., 1) - Response:
{ "message": "User deleted successfully", "newData": [...] }
- Method:
$ yarn install
Running the app
# development
$ yarn run start
# watch mode
$ yarn run start:dev
# production mode
$ yarn run start:prod
Test
# unit tests
$ yarn run test
# e2e tests
$ yarn run test:e2e
# test coverage
$ yarn run test:cov
Support
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
Stay in touch
Author - Muhammad Mutahir
Website - https://nestjs.com
Twitter - @nestframework
License
Nest is MIT licensed.