This controller handles user-related operations using UserService and Prisma.
-
POST /user
- Creates a new user.
- Parameters: A
createUserDtoobject in the body of the request, of typePrisma.UserCreateInput.
-
GET /user
- Retrieves all users.
- Response: An array of users.
-
GET /user/:id
- Retrieves a specific user by their
id. - Parameter:
idin the URL, of typestring. - Response: The user corresponding to the
id.
- Retrieves a specific user by their
-
PATCH /user/:id
- Updates an existing user.
- Parameter:
idin the URL, of typestring. - Request Body: A
updateUserDtoobject of typePrisma.UserUpdateInput.
-
DELETE /user/:id
- Deletes a user by their
id. - Parameter:
idin the URL, of typestring. - Response: Confirmation of deletion.
- Deletes a user by their
-
Create a user:
Send aPOSTrequest with a JSON object in the body (e.g., name, email, etc.). -
Get all users:
Send aGETrequest to/user. -
Update a user:
Send aPATCHrequest with the user'sidand the data to be updated.
To use this API, ensure that you have installed the necessary dependencies:
-
Install NestJS and Prisma:
npm install @nestjs/common @nestjs/core @nestjs/platform-express prisma
-
Set up the Prisma database models and migrate:
npx prisma db push
-
Start the application:
npm run start
Now, your API should be ready to handle user management with the UserController.
"# WasteManagementBackend"