Initial commit: NestJS backend for Child Gold Land
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { Body, Controller, HttpCode, Inject, Post, forwardRef } from '@nestjs/common'
|
||||
import { Public } from '../common/decorators/public.decorator'
|
||||
import { strictBodyPipe } from '../common/pipes/strict-body.pipe'
|
||||
import { AuthService } from './auth.service'
|
||||
import { LoginDto } from './dto/login.dto'
|
||||
import { RegisterDto } from './dto/register.dto'
|
||||
|
||||
@Controller('api/auth')
|
||||
export class AuthController {
|
||||
constructor(@Inject(forwardRef(() => AuthService)) private readonly auth: AuthService) {}
|
||||
|
||||
@Public()
|
||||
@HttpCode(200)
|
||||
@Post('register')
|
||||
register(@Body(strictBodyPipe(RegisterDto)) dto: RegisterDto) {
|
||||
return this.auth.register(dto.username, dto.password, dto.name)
|
||||
}
|
||||
|
||||
@Public()
|
||||
@HttpCode(200)
|
||||
@Post('login')
|
||||
login(@Body(strictBodyPipe(LoginDto)) dto: LoginDto) {
|
||||
return this.auth.login(dto.username, dto.password)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user