updated and runned and tested
This commit is contained in:
44
ServicesApi/src/users/users.controller.ts
Normal file
44
ServicesApi/src/users/users.controller.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Param,
|
||||
Body,
|
||||
} from '@nestjs/common';
|
||||
import { UsersService } from './users.service';
|
||||
import { User } from '@prisma/client';
|
||||
|
||||
@Controller('users')
|
||||
export class UsersController {
|
||||
constructor(private usersService: UsersService) {}
|
||||
|
||||
@Get()
|
||||
async findAll(): Promise<User[]> {
|
||||
return this.usersService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
async findOne(@Param('id') id: string): Promise<User | null> {
|
||||
return this.usersService.findOne(Number(id));
|
||||
}
|
||||
|
||||
@Post()
|
||||
async create(@Body() data: { name: string; email: string }): Promise<User> {
|
||||
return this.usersService.create(data);
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
async update(
|
||||
@Param('id') id: string,
|
||||
@Body() data: Partial<{ name: string; email: string }>,
|
||||
): Promise<User> {
|
||||
return this.usersService.update(Number(id), data);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async remove(@Param('id') id: string): Promise<User> {
|
||||
return this.usersService.remove(Number(id));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user