Commit aabf6f85 authored by Pavel Mishakov's avatar Pavel Mishakov

fixes

parent ca2b7957
......@@ -25,6 +25,7 @@ export class ProductsController {
this.router.get('/', this.getProducts)
this.router.get('/:id', this.getProductById)
this.router.post('/', upload.single('image'), this.addProduct)
this.router.delete('/:id', this.deleteProductById)
this.service = productService
}
......@@ -49,4 +50,9 @@ export class ProductsController {
const response = await this.service.addProduct(product)
res.send(response)
}
private deleteProductById = async (req: Request, res: Response): Promise<void> => {
const response = await this.service.deleteProductById(req.params.id)
res.send(response)
}
}
\ No newline at end of file
......@@ -77,7 +77,7 @@ export class Mongo implements IDataBase {
const data = await product.save()
const response: IResponse<IProduct> = {
status: EStatuses.OK,
result: data as any,
result: data,
message: ''
}
return response
......@@ -97,7 +97,7 @@ export class Mongo implements IDataBase {
const data = await Product.findOneAndDelete({_id: id})
const response: IResponse<IProduct> = {
status: EStatuses.OK,
result: data as any,
result: data,
message: ''
}
return response
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment