Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codespace turbo zebra qjjx5prwp9939jj #13

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
![StackUp Banner]([https://tinkerhub.frappe.cloud/files/stackup%20banner.jpeg])
# Project Name
# E-COMMERCE WEBSITE
Long Description about project. This project do that. This project is awesome...
## Team members
1. Name [Embed personal github URL]
2. Name [Embed perosnal github URL]
1. Asna [https://github.com/asnasharin28]
2. Hasna
3. Fidha [https://github.com/Fidha07]
4. Sreeyuktha[https://github.com/SREEYUKTHA-SNL]
5. Munna[https://github.com/munna710]
## Team Id
Team id here
hikeup
## Link to product walkthrough
[link to video]
## How it Works ?
Expand Down
1 change: 1 addition & 0 deletions ecommerce/backend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MONGODB_URL = mongodb://localhost:27017/ecommerce_db
12 changes: 12 additions & 0 deletions ecommerce/backend/config/dbConnect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const mongoose = require("mongoose");

const dbConnect = async () => {
try {
const conn = await mongoose.connect(process.env.MONGODB_URL);
console.log("Database Connected Successfully");
} catch (error) {
console.error("Error connecting to the database:", error.message);
}
};

module.exports = dbConnect;
25 changes: 25 additions & 0 deletions ecommerce/backend/controller/userCtrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const User = require("../models/userModel");
const asyncHandler = require("express-async-handler");
const createUser = asyncHandler(async (req, res) => {
try {
// Extract email from the request body
const email = req.body.email;

// Check if a user with the given email already exists in the database
const findUser = await User.findOne({ email: email });

if (!findUser) {
// If user not found, create a new user using the request body
const newUser = await User.create(req.body);
res.json(newUser); // Send the newly created user as the response
} else {
// If user found, throw an error indicating that the user already exists
throw new Error("User Already Exists");
}
} catch (error) {
// Handle any errors that occur during the process
res.status(400).json({ message: error.message }); // Send an error response with the error message
}
});

module.exports = {createUser}
15 changes: 15 additions & 0 deletions ecommerce/backend/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const express = require("express");
const app = express();
const dbConnect = require("./config/dbConnect");
const dotenv = require("dotenv").config();
const bodyParser = require('body-parser');
const PORT = 5000;
const authRouter = require("./routes/authRoute");
dbConnect();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));

app.use("/api/user", authRouter);
app.listen(PORT, () => {
console.log(`Server is running at PORT ${PORT}`);
});
30 changes: 30 additions & 0 deletions ecommerce/backend/models/userModel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const mongoose = require("mongoose"); // Erase if already required
const bcrypt = require("bcrypt");
const crypto = require("crypto");
// Declare the Schema of the Mongo model
var userSchema = new mongoose.Schema(
{
firstname: {
type: String,
required: true,
},
lastname: {
type: String,
required: true,
},
email: {
type: String,
required: true,
unique: true,
},
mobile: {
type: String,
required: true,
unique: true,
},
password: {
type: String,
required: true,
}
});
module.exports = mongoose.model("User", userSchema);
1 change: 1 addition & 0 deletions ecommerce/backend/node_modules/.bin/color-support

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ecommerce/backend/node_modules/.bin/mime

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ecommerce/backend/node_modules/.bin/mkdirp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ecommerce/backend/node_modules/.bin/node-pre-gyp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ecommerce/backend/node_modules/.bin/nodemon

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ecommerce/backend/node_modules/.bin/nodetouch

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ecommerce/backend/node_modules/.bin/nopt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ecommerce/backend/node_modules/.bin/rimraf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ecommerce/backend/node_modules/.bin/semver

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading