-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathauth.controller.ts
46 lines (41 loc) · 1.39 KB
/
auth.controller.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { Body, Controller, HttpCode, HttpStatus, Post } from "@nestjs/common";
import { SignInDto } from "./dto/sign-in.dto";
import { AuthService } from "./auth.service";
import { Public } from "../decorator/public-route.decorator";
import { SignUpDto } from "./dto/sign-up.dto";
import {
ConfirmEmailResponse,
SignInResponse,
SignUpResponse,
} from "../model/response.model";
import { EmailConfirmationDto } from "./dto/email-confirmation.dto";
import { RefreshTokenDto } from "./dto/refresh-token.dto";
@Controller("auth")
export class AuthController {
constructor(private readonly authService: AuthService) {}
@Public()
@Post("sign-in")
@HttpCode(HttpStatus.OK)
async signIn(@Body() signInDto: SignInDto): Promise<SignInResponse> {
return await this.authService.signIn(signInDto);
}
@Public()
@Post("sign-up")
async signUp(@Body() signUpDto: SignUpDto): Promise<SignUpResponse> {
return await this.authService.signUp(signUpDto);
}
@Public()
@Post("confirm-email")
@HttpCode(HttpStatus.OK)
async confirmEmail(
@Body() emailConfirmationDto: EmailConfirmationDto,
): Promise<ConfirmEmailResponse> {
return await this.authService.confirmEmail(emailConfirmationDto);
}
@Public()
@Post("refresh")
@HttpCode(HttpStatus.OK)
async refresh(@Body() refreshTokenDto: RefreshTokenDto) {
return await this.authService.refresh(refreshTokenDto.refreshToken);
}
}