UI support for products!
This commit is contained in:
parent
013202546b
commit
29f4983a15
18 changed files with 21172 additions and 20 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { Request, Response } from "express";
|
||||
import Products from "../../../models/Product";
|
||||
import { LOGGER } from "../../../util/Logger";
|
||||
import { Types } from "mongoose";
|
||||
|
||||
export default async (req: Request, res: Response) => {
|
||||
try {
|
||||
|
|
@ -10,7 +11,7 @@ export default async (req: Request, res: Response) => {
|
|||
.json({ error: "Request is missing Parameter 'id'" });
|
||||
}
|
||||
|
||||
const product = await Products.findById(req.params.id);
|
||||
const product = await Products.findById(new Types.ObjectId(req.params.id));
|
||||
if (!product) {
|
||||
return res
|
||||
.status(404)
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ export type Review = Document & {
|
|||
|
||||
export type ProductModel = Document & {
|
||||
name: string;
|
||||
description: string;
|
||||
quantity: number;
|
||||
price: number;
|
||||
images: string[];
|
||||
|
|
@ -43,6 +44,10 @@ const ProductSchema = new Schema<ProductModel>({
|
|||
type: String,
|
||||
required: true,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
quantity: {
|
||||
type: Number,
|
||||
required: true,
|
||||
|
|
|
|||
Loading…
Reference in a new issue