UI support for products!
This commit is contained in:
parent
013202546b
commit
29f4983a15
18 changed files with 21172 additions and 20 deletions
19
backend/init.js
Normal file
19
backend/init.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
const user = require("./dist/app/models/User").default;
|
||||
const mongoose = require('mongoose');
|
||||
|
||||
const init = async () => {
|
||||
await mongoose.connect(
|
||||
`mongodb://${process.env.MONGO_URI}/${process.env.MONGO_COLLECTION}`,
|
||||
{ autoIndex: true }
|
||||
);
|
||||
|
||||
await user.updateOne({ email: 'stovallj1995@gmail.com' }, { $set: { admin: true } });
|
||||
|
||||
// const u = new user();
|
||||
// u.email = "stovallj1995@gmail.com";
|
||||
// u.password = u.hashPassword("hotdog123");
|
||||
// u.isEmailValidated = true;
|
||||
// await u.save();
|
||||
};
|
||||
|
||||
init().then(process.exit);
|
||||
2053
backend/package-lock.json
generated
2053
backend/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -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