Skip to content

Commit

Permalink
integerated backend
Browse files Browse the repository at this point in the history
  • Loading branch information
1010varun committed Oct 29, 2023
1 parent d6a4420 commit 3625626
Show file tree
Hide file tree
Showing 5 changed files with 7,001 additions and 19,197 deletions.
14 changes: 8 additions & 6 deletions backend/models.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { json } = require("express");
const mongoose = require("mongoose");


Expand All @@ -15,12 +16,13 @@ const farmer = new mongoose.Schema({
});

const product = new mongoose.Schema({
productID: { type: String, required: true },
name: { type: String, required: true },
quantity: { type: String, required: true },
prize_high: { type: String, required: true },
prize_low: { type: String, required: true },
// is_finished: { type: String, required: true },
title: { type: String, required: true },
price: { type: String, required: true },
imageUrl: { type: String, required: true },
category: { type: String, required: true },
description: { type: String, required: true },
time: { type: Object, required: true },
date: { type: String, required: true },
});

const customer = new mongoose.Schema({
Expand Down
27 changes: 16 additions & 11 deletions backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,24 @@ app.get("/orders", async (req, res) => {
app.post("/products", async (req, res) => {
try {
const {
name,
quantity,
prize_high,
prize_low
title,
price,
imageUrl,
category,
description,
time,
date,
} = req.body

const data = {
productID: uid(),
name,
quantity,
prize_high,
prize_low
}
title,
price,
imageUrl,
category,
description,
time,
date,
};

await Product.create(data)

Expand Down Expand Up @@ -86,7 +91,7 @@ app.post("/order", async (req, res) => {
}
});

const port = process.env.PORT || 5000;
const port = 5000;

const connectDatabase = async () => {
try {
Expand Down
Loading

0 comments on commit 3625626

Please sign in to comment.