feat: implement authentication and product management services with validation schemas

This commit is contained in:
2026-01-13 00:04:13 +03:00
parent da428f83bc
commit ae6521977d
6 changed files with 171 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
import { Request, Response, NextFunction } from "express";
import { ProductService } from "../services/product.service";
export class ProductController {
static async create(req: Request, res: Response, next: NextFunction) {
try {
const product = await ProductService.create(req.body);
res.status(201).json(product);
} catch (err) {
next(err);
}
}
static async list(_req: Request, res: Response, next: NextFunction) {
try {
const products = await ProductService.list();
res.status(200).json(products);
} catch (err) {
next(err);
}
}
static async update(req: Request, res: Response, next: NextFunction) {
try {
const { id } = req.params;
const product = await ProductService.update(id, req.body);
res.status(200).json(product);
} catch (err) {
next(err);
}
}
}