parent
3c216fa12a
commit
69c0a65ad5
2 changed files with 36 additions and 48 deletions
@ -1,21 +1,20 @@ |
|||||||
import { Controller, Post, Body, Res, UseGuards, Get } from "@nestjs/common"; |
import { Controller, Post, Body, Res, UseGuards, Get } from "@nestjs/common"; |
||||||
import { UsersService } from "./users.service"; |
import { UsersService } from "./users.service"; |
||||||
import { Response } from "express"; |
import { User } from "./entities/user.entity"; |
||||||
import { JwtAuthGuard } from "src/guard/auth.guard"; |
|
||||||
|
|
||||||
@Controller("users") |
@Controller("user") |
||||||
export class UsersController { |
export class UsersController { |
||||||
constructor(private readonly usersService: UsersService) {} |
constructor(private readonly usersService: UsersService) {} |
||||||
|
|
||||||
@Post("register") |
@Post("register") |
||||||
async register(@Body() body: { email: string; password: string }, @Res() res: Response): Promise<Response> { |
async register(@Body() body: { email: string; password: string }):Promise<User> { |
||||||
const { email, password } = body; |
const { email, password } = body; |
||||||
return this.usersService.register(email, password, res); |
return this.usersService.register(email, password); |
||||||
} |
} |
||||||
|
|
||||||
@Post("login") |
@Post("login") |
||||||
async login(@Body() body: { email: string; password: string }, @Res() res: Response): Promise<Response> { |
async login(@Body() body: { email: string; password: string }):Promise<{token}> { |
||||||
const { email, password } = body; |
const { email, password } = body; |
||||||
return this.usersService.login(email, password, res); |
return this.usersService.login(email, password); |
||||||
} |
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue