[NestJS] redirect > Node/Flutter/Dart

본문 바로가기

사이트 내 전체검색

Node/Flutter/Dart

[NestJS] redirect

작성일 24-05-08 23:46

페이지 정보

작성자sbLAB 조회 34회 댓글 0건

본문

auth.controller.ts 


import {
  Body,
  Controller,
  Get,
  Post,
  HttpCode,
  Render,
  HttpStatus,
  Header,
  Res,
  Redirect,
} from '@nestjs/common';
import { AuthService } from './auth.service';
import { UserDto } from 'src/user/dto/UserDto';
import { response } from 'express';

@Controller('auth')
export class AuthController {
  constructor(private authService: AuthService) {}

  @Get()
  @Render('auth/auth') //auth index page
  authView() {
    return this.authService.authView();
  }

  @Get('logout') //auth logout execution
  authLogOutExec() {
    const result = this.authService.authLogOutExec();
  }

  @Post('signup') //auth signup execution
  @HttpCode(HttpStatus.CREATED) //201
  //@Redirect('/', 301) //함수 실행종료후 리다이렉션
  //Common HTTP Status Codes
  //200 OK: The request was successful.
  //201 Created: The request was successful, and a new resource was created.
  //400 Bad Request: The server could not understand the request.
  //404 Not Found: The requested resource could not be found
  async authSignUpExec(@Body() userDto: UserDto, @Res() res) {
    const result = await this.authService.authSignUpExec(userDto);
    return res.redirect('/');
  }

OR

  @Post('signup') //auth signup execution
  @HttpCode(HttpStatus.CREATED) //201
  @Redirect('/', 301) //함수 실행종료후 리다이렉션
  //Common HTTP Status Codes
  //200 OK: The request was successful.
  //201 Created: The request was successful, and a new resource was created.
  //400 Bad Request: The server could not understand the request.
  //404 Not Found: The requested resource could not be found
  async authSignUpExec(@Body() userDto: UserDto, @Res() res) {
    const result = await this.authService.authSignUpExec(userDto);
//return res.redirect('/');

}
 


댓글목록

등록된 댓글이 없습니다.

Copyright © 소유하신 도메인. All rights reserved.
PC 버전으로 보기