parent
ad738f2c61
commit
4a2c479879
4 changed files with 72 additions and 27 deletions
@ -1,17 +1,18 @@ |
|||||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'; |
import { Controller, Get, Post, Body, Patch, Param, Delete } from "@nestjs/common"; |
||||||
import { AdminService } from './admin.service'; |
import { AdminService } from "./admin.service"; |
||||||
import { Injectable, UnauthorizedException } from '@nestjs/common'; |
import { Admin } from "./entities/admin.entity"; |
||||||
import { InjectModel } from '@nestjs/sequelize'; |
|
||||||
import { Admin } from './entities/admin.entity'; |
|
||||||
import * as bcrypt from 'bcrypt'; |
|
||||||
import { JwtService } from '@nestjs/jwt'; |
|
||||||
|
|
||||||
@Controller('admin') |
@Controller("admin") |
||||||
export class AdminController { |
export class AdminController { |
||||||
constructor(private readonly adminService: AdminService) {} |
constructor(private readonly adminService: AdminService) {} |
||||||
@Post('register') |
@Post("register") |
||||||
async register(@Body() body:{email: string, password: string}):Promise<Admin>{ |
async register(@Body() body: { email: string; password: string }): Promise<Admin> { |
||||||
const {email, password} = body |
const { email, password } = body; |
||||||
return this.adminService.register(email, password); |
return this.adminService.register(email, password); |
||||||
} |
} |
||||||
|
@Post("login") |
||||||
|
async login(@Body() body: { email: string; password: string }): Promise<{ token: string }> { |
||||||
|
const { email, password } = body; |
||||||
|
return this.adminService.login(email, password); |
||||||
|
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue