packages/server/src/modules/auth/auth.controller.ts
auth
Methods |
profile | ||||||
profile(user: ActiveUserData)
|
||||||
Decorators :
@HttpCode(HttpStatus.OK)
|
||||||
Parameters :
Returns :
Promise<>
|
signIn | ||||||
signIn(signInDto: AuthRequest)
|
||||||
Decorators :
@HttpCode(HttpStatus.OK)
|
||||||
Parameters :
Returns :
any
|
signOut | ||||||
signOut(userId: string)
|
||||||
Decorators :
@HttpCode(HttpStatus.OK)
|
||||||
Parameters :
Returns :
Promise<void>
|
import {
Controller,
Post,
Body,
HttpCode,
HttpStatus,
Request,
Get,
} from "@nestjs/common";
import { ActiveUser } from "@/common/decorators/active-user.decorator";
import { Public } from "@/common/decorators/public.decorator";
import { ActiveUserData } from "@/common/interfaces/active-user-data.interface";
import { AuthRequest } from "./auth.interface";
import { AuthService } from "./auth.service";
type RequestWithUser = Request & {
user: unknown;
};
@Controller("auth")
export class AuthController {
constructor(private readonly authService: AuthService) {}
@HttpCode(HttpStatus.OK)
@Public()
@Post("sign-in")
signIn(@Body() signInDto: AuthRequest) {
return this.authService.login(signInDto);
}
@HttpCode(HttpStatus.OK)
@Get("profile")
profile(
@ActiveUser() user: ActiveUserData
): Promise<unknown> {
return this.authService.profile(user);
}
@HttpCode(HttpStatus.OK)
@Post("sign-out")
signOut(@ActiveUser("id") userId: string): Promise<void> {
return this.authService.signOut(userId);
}
}