feat: init project and add user module
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
Param,
|
||||
ParseIntPipe,
|
||||
Post,
|
||||
} from '@nestjs/common';
|
||||
import { CreateUserDTO } from './dto/create-user.dto';
|
||||
import { UsersService } from './providers/users.service';
|
||||
|
||||
@Controller('users')
|
||||
export class UsersController {
|
||||
constructor(
|
||||
/**
|
||||
* Injecting Users Service
|
||||
*/
|
||||
private readonly usersService: UsersService,
|
||||
) {}
|
||||
|
||||
@Get()
|
||||
public getAllUsers() {
|
||||
return ['user1', 'user2'];
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
public getUserById(@Param('id', ParseIntPipe) id: number) {
|
||||
return `user ${id}`;
|
||||
}
|
||||
|
||||
@Post()
|
||||
public async createUser(@Body() createUserDto: CreateUserDTO) {
|
||||
return await this.usersService.createOne(createUserDto);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user