diff --git a/src/app.module.ts b/src/app.module.ts index c9109df..0522777 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -5,6 +5,7 @@ import { ConfigModule } from "@nestjs/config"; import { SequelizeModule } from "@nestjs/sequelize"; import { databaseConfig } from "./config/database.config"; import { UsersModule } from './users/users.module'; +import { ProductsModule } from './products/products.module'; @Module({ imports: [ @@ -13,6 +14,7 @@ import { UsersModule } from './users/users.module'; }), SequelizeModule.forRoot(databaseConfig), UsersModule, + ProductsModule, ], controllers: [AppController], providers: [AppService], diff --git a/src/products/entities/product.entity.ts b/src/products/entities/product.entity.ts new file mode 100644 index 0000000..3f0c516 --- /dev/null +++ b/src/products/entities/product.entity.ts @@ -0,0 +1,22 @@ +import { Model, Table, Column, DataType } from "sequelize-typescript"; + +@Table +export class Product extends Model { + @Column({ + type: DataType.STRING, + allowNull: false, + }) + name: string; + + @Column({ + type: DataType.STRING, + allowNull: false, + }) + description: string; + + @Column({ + type: DataType.DECIMAL(10, 2), + allowNull: false, + }) + price: number; +} diff --git a/src/products/products.controller.ts b/src/products/products.controller.ts new file mode 100644 index 0000000..1d46209 --- /dev/null +++ b/src/products/products.controller.ts @@ -0,0 +1,8 @@ +import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'; +import { ProductsService } from './products.service'; + +@Controller('products') +export class ProductsController { + constructor(private readonly productsService: ProductsService) {} + +} diff --git a/src/products/products.module.ts b/src/products/products.module.ts new file mode 100644 index 0000000..1697bce --- /dev/null +++ b/src/products/products.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { ProductsService } from './products.service'; +import { ProductsController } from './products.controller'; + +@Module({ + controllers: [ProductsController], + providers: [ProductsService], +}) +export class ProductsModule {} diff --git a/src/products/products.service.ts b/src/products/products.service.ts new file mode 100644 index 0000000..9eb03f4 --- /dev/null +++ b/src/products/products.service.ts @@ -0,0 +1,6 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class ProductsService { + +} diff --git a/src/users/users.controller.ts b/src/users/users.controller.ts index e74855d..199a310 100644 --- a/src/users/users.controller.ts +++ b/src/users/users.controller.ts @@ -1,25 +1,20 @@ -import { Controller, Post, Body, Res } from '@nestjs/common'; -import { UsersService } from './users.service'; -import { Response } from 'express'; +import { Controller, Post, Body, Res, UseGuards, Get } from "@nestjs/common"; +import { UsersService } from "./users.service"; +import { Response } from "express"; +import { JwtAuthGuard } from "src/guard/auth.guard"; -@Controller('users') +@Controller("users") export class UsersController { constructor(private readonly usersService: UsersService) {} - @Post('register') - async register( - @Body() body: { email: string; password: string }, - @Res() res: Response - ): Promise { + @Post("register") + async register(@Body() body: { email: string; password: string }, @Res() res: Response): Promise { const { email, password } = body; return this.usersService.register(email, password, res); } - @Post('login') - async login( - @Body() body: { email: string; password: string }, - @Res() res: Response - ): Promise { + @Post("login") + async login(@Body() body: { email: string; password: string }, @Res() res: Response): Promise { const { email, password } = body; return this.usersService.login(email, password, res); }