diff --git a/backend/.gitignore b/backend/.gitignore index 11ddd8d..b6d813a 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -1,3 +1,4 @@ node_modules # Keep environment variables out of version control .env +dist diff --git a/backend/src/repositories/product.repository.ts b/backend/src/repositories/product.repository.ts index 49a0403..cb12b15 100644 --- a/backend/src/repositories/product.repository.ts +++ b/backend/src/repositories/product.repository.ts @@ -43,7 +43,7 @@ class ProductRepository implements ProductProvider { ): Promise => { try { const product: PrismaProduct | null = await prisma.product.findUnique({ - where: { id: getProduct.params.id }, + where: { id: getProduct.id }, }); if (product === null) { throw new ProductNotFoundError(); @@ -74,14 +74,14 @@ class ProductRepository implements ProductProvider { try { const newProduct: PrismaProduct = await prisma.product.create({ data: { - title: createProduct.body.title, - size: createProduct.body.size, - color: createProduct.body.color, - description: createProduct.body.description, - gender: createProduct.body.gender, - category: createProduct.body.category, - price: createProduct.body.price, - imageUrl: createProduct.body.imageUrl, + title: createProduct.title, + size: createProduct.size, + color: createProduct.color, + description: createProduct.description, + gender: createProduct.gender, + category: createProduct.category, + price: createProduct.price, + imageUrl: createProduct.imageUrl, }, }); return newProduct; @@ -107,7 +107,7 @@ class ProductRepository implements ProductProvider { ): Promise => { try { const product: PrismaProduct | null = await prisma.product.delete({ - where: { id: getProduct.params.id }, + where: { id: getProduct.id }, }); if (product === null) { throw new ProductNotFoundError(); diff --git a/backend/src/repositories/scanner.repository.ts b/backend/src/repositories/scanner.repository.ts index 4f92266..46c050b 100644 --- a/backend/src/repositories/scanner.repository.ts +++ b/backend/src/repositories/scanner.repository.ts @@ -14,7 +14,7 @@ class ScannerRepository implements ScannerProvider { try { const worker: Tesseract.Worker = await createWorker("eng"); const ret: Tesseract.RecognizeResult = await worker.recognize( - scannerRequest.body.imageUrl + scannerRequest.imageUrl ); await worker.terminate(); return ret.data.text; diff --git a/backend/src/routes/scanner.routes.ts b/backend/src/routes/scanner.routes.ts index 1017eb5..b8ebd61 100644 --- a/backend/src/routes/scanner.routes.ts +++ b/backend/src/routes/scanner.routes.ts @@ -3,7 +3,7 @@ import ScannerService from "../services/scanner.service.js"; import ScannerRepository from "../repositories/scanner.repository.js"; import schemaValidation from "../middlewares/schemaValidation.middleware.js"; import { Router } from "express"; -import { scannerSchema } from "../schemas/scanner.schema.js"; +import { ScannerSchema } from "../schemas/scanner.schema.js"; const scannerRouter = Router(); const scannerController = new ScannerController( @@ -12,7 +12,7 @@ const scannerController = new ScannerController( scannerRouter.post( "/", - schemaValidation(scannerSchema), + schemaValidation(ScannerSchema), scannerController.postMaterials ); diff --git a/backend/src/types.ts b/backend/src/types.ts index b02ba81..a1d8336 100644 --- a/backend/src/types.ts +++ b/backend/src/types.ts @@ -26,8 +26,8 @@ export type Tag = { percentage: string; }; -export type CreateProduct = z.infer; +export type CreateProduct = z.infer["body"]; -export type GetProduct = z.infer; +export type GetProduct = z.infer["params"]; -export type ScannerRequest = z.infer; +export type ScannerRequest = z.infer["body"];