25 lines
598 B
TypeScript
25 lines
598 B
TypeScript
|
import { Controller, Get, Post, Body, Param } from '@nestjs/common'
|
||
|
import { UsersService } from './users.service'
|
||
|
|
||
|
@Controller()
|
||
|
export class UsersController {
|
||
|
constructor(private readonly userService: UsersService) {}
|
||
|
|
||
|
@Get('users')
|
||
|
async findUsers() {
|
||
|
return this.userService.findUsers()
|
||
|
}
|
||
|
|
||
|
@Get('users/:id')
|
||
|
async getUserInfo(@Param('id') id: string) {
|
||
|
return this.userService.getUserInfo(id)
|
||
|
}
|
||
|
|
||
|
@Post('users')
|
||
|
async createUser(
|
||
|
@Body() userData: { email: string; password: string; username?: string },
|
||
|
) {
|
||
|
return this.userService.createUser(userData)
|
||
|
}
|
||
|
}
|