File

packages/server/src/modules/auth/auth.controller.ts

Prefix

auth

Index

Methods

Methods

profile
profile(user: ActiveUserData)
Decorators :
@HttpCode(HttpStatus.OK)
@Get('profile')
Parameters :
Name Type Optional
user ActiveUserData No
Returns : Promise<>
signIn
signIn(signInDto: AuthRequest)
Decorators :
@HttpCode(HttpStatus.OK)
@Public()
@Post('sign-in')
Parameters :
Name Type Optional
signInDto AuthRequest No
Returns : any
signOut
signOut(userId: string)
Decorators :
@HttpCode(HttpStatus.OK)
@Post('sign-out')
Parameters :
Name Type Optional
userId string No
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);
  }
}

results matching ""

    No results matching ""