forked from swapnil.bendal/TypeScript-Backend-Template
[fixed] - issue
This commit is contained in:
@@ -10,13 +10,13 @@ export class ProductController {
|
||||
this.interactor = interactor;
|
||||
}
|
||||
|
||||
// @AsyncHandler()
|
||||
@AsyncHandler()
|
||||
async onCreateProduct(req: Request, res: Response, next: NextFunction) {
|
||||
const data = await this.interactor.createProduct(req.body);
|
||||
res.status(201).json(new ApiResponse(201, data, 'Successfully created'));
|
||||
}
|
||||
|
||||
// @AsyncHandler()
|
||||
@AsyncHandler()
|
||||
async onGetProducts(req: Request, res: Response, next: NextFunction) {
|
||||
const offset = parseInt(`${req.query.offset}`) || 0;
|
||||
const limit = parseInt(`${req.query.limit}`) || 10;
|
||||
@@ -24,12 +24,13 @@ export class ProductController {
|
||||
|
||||
if (data.length === 0) {
|
||||
res.status(204).json(new ApiResponse(204, null, 'No products found'));
|
||||
return;
|
||||
}
|
||||
|
||||
res.status(200).json(new ApiResponse(200, data, 'Products retrieved successfully'));
|
||||
}
|
||||
|
||||
// @AsyncHandler()
|
||||
@AsyncHandler()
|
||||
async onUpdateStock(req: Request, res: Response, next: NextFunction) {
|
||||
const data = await this.interactor.updateStock(parseInt(`${req.params.id}`), parseInt(`${req.body.stock}`));
|
||||
res.status(200).json(new ApiResponse(200, data, 'Successfully updated'));
|
||||
|
||||
Reference in New Issue
Block a user