From 01176a02dc342461c8773aae2cc8b96dd13dd7ae Mon Sep 17 00:00:00 2001 From: Parth Kumar Singh Date: Mon, 2 Oct 2023 23:02:41 +0530 Subject: [PATCH 1/7] added responsiveness --- src/css/course.css | 57 ++++++++++--- src/css/login.css | 11 +++ src/css/profile.css | 187 ++++++++++++++++++++++++------------------- src/css/register.css | 174 ++++++++++++++++++++++------------------ 4 files changed, 256 insertions(+), 173 deletions(-) diff --git a/src/css/course.css b/src/css/course.css index 8c6da6c..b191388 100644 --- a/src/css/course.css +++ b/src/css/course.css @@ -7,20 +7,21 @@ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); background-color: #fff; padding: 20px; -} - -.course-box { display: flex; + flex-wrap: wrap; } .course-image { flex-basis: 30%; + margin-bottom: 20px; } .course-image img { width: 200px; height: 150px; border-radius: 4px; + display: block; + margin: 0 auto; } .course-details { @@ -28,14 +29,6 @@ padding-left: 40px; } -.course-box img { - width: 200px; - height: 150px; - display: block; - margin: 0 auto; - border-radius: 4px; -} - .course-box h1 { font-size: 24px; margin-top: 10px; @@ -51,6 +44,7 @@ .course-list-container { display: flex; + flex-wrap: wrap; } .course-container { @@ -58,3 +52,44 @@ margin: 0 auto; padding: 20px; } + +/* Mobile screens */ +@media only screen and (max-width: 600px) { + .course-box { + flex-direction: column; + } + .course-image { + flex-basis: 100%; + } + .course-details { + padding-left: 0; + } +} + +/* Tablet screens */ +@media only screen and (min-width: 601px) and (max-width: 1024px) { + .course-box { + flex-direction: row; + } + .course-image { + flex-basis: 30%; + } + .course-details { + padding-left: 20px; + } +} + +/* Laptop screens */ +@media only screen and (min-width: 1025px) { + .course-box { + flex-direction: row; + max-width: 1200px; + margin: 0 auto; + } + .course-image { + flex-basis: 30%; + } + .course-details { + padding-left: 50px; + } +} diff --git a/src/css/login.css b/src/css/login.css index 9183b7f..30b298b 100644 --- a/src/css/login.css +++ b/src/css/login.css @@ -15,6 +15,8 @@ body { border-radius: 5px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); text-align: center; + width: 100%; /* Ensures it takes the full width on mobile */ + max-width: 400px; /* Restricts its width on larger screens */ } h1 { @@ -38,6 +40,7 @@ input[type="password"] { padding: 10px; border: 1px solid #ccc; border-radius: 3px; + font-size: 14px; /* Adjust for better mobile readability */ } button { @@ -47,6 +50,7 @@ button { padding: 10px 20px; border-radius: 3px; cursor: pointer; + width: 100%; /* Full width on mobile for better touch targets */ } button:hover { @@ -56,3 +60,10 @@ button:hover { p { margin-top: 10px; } + +/* Media Query for Larger Devices */ +@media screen and (min-width: 768px) { + button { + width: auto; /* Resetting button width for larger screens */ + } +} diff --git a/src/css/profile.css b/src/css/profile.css index f0acb7c..ab1d1eb 100644 --- a/src/css/profile.css +++ b/src/css/profile.css @@ -1,91 +1,110 @@ /* Reset some default styles */ body { - margin: 0; - padding: 0; - font-family: Arial, sans-serif; - } - - /* Header styles */ - header { - background-color: #333; - color: white; - padding: 10px; - text-align: center; - } - - /* Profile container */ - .profile-container { - max-width: 800px; - margin: 0 auto; - padding: 20px; - } - - /* Profile section */ - .profile-section { - background-color: #f9f9f9; - border: 1px solid #ddd; - border-radius: 5px; - padding: 20px; - margin-bottom: 20px; - } - - /* Profile section title */ - .profile-section h2 { - margin-top: 0; - font-size: 24px; - } - - /* Profile form */ - .profile-form { - display: flex; - flex-wrap: wrap; - } - - /* Profile form fields */ + margin: 0; + padding: 0; + font-family: Arial, sans-serif; +} + +/* Header styles */ +header { + background-color: #333; + color: white; + padding: 10px; + text-align: center; +} + +/* Profile container */ +.profile-container { + max-width: 800px; + margin: 0 auto; + padding: 20px; +} + +/* Profile section */ +.profile-section { + background-color: #f9f9f9; + border: 1px solid #ddd; + border-radius: 5px; + padding: 20px; + margin-bottom: 20px; +} + +/* Profile section title */ +.profile-section h2 { + margin-top: 0; + font-size: 24px; +} + +/* Profile form */ +.profile-form { + display: flex; + flex-wrap: wrap; +} + +/* Profile form fields */ +.profile-form .form-group { + width: 100%; + margin-bottom: 15px; +} + +/* Profile form labels */ +.profile-form label { + display: block; + font-weight: bold; +} + +/* Profile form input fields */ +.profile-form input[type="text"], +.profile-form input[type="email"] { + width: 100%; + padding: 10px; + border: 1px solid #ddd; + border-radius: 5px; +} + +/* Profile form submit button */ +.profile-form .submit-btn { + background-color: #333; + color: white; + border: none; + border-radius: 5px; + padding: 10px 20px; + cursor: pointer; + width: 100%; +} + +/* Profile form submit button on hover */ +.profile-form .submit-btn:hover { + background-color: #555; +} + +/* Error message styles */ +.error-message { + color: red; + margin-top: 5px; +} + +/* Success message styles */ +.success-message { + color: green; + margin-top: 5px; +} + +/* Tablet screens */ +@media screen and (min-width: 601px) and (max-width: 1024px) { .profile-form .form-group { - width: 100%; - margin-bottom: 15px; + width: 50%; + padding: 0 10px; } - - /* Profile form labels */ - .profile-form label { - display: block; - font-weight: bold; - } - - /* Profile form input fields */ - .profile-form input[type="text"], - .profile-form input[type="email"] { - width: 100%; - padding: 10px; - border: 1px solid #ddd; - border-radius: 5px; +} + +/* Laptop screens */ +@media screen and (min-width: 1025px) { + .profile-form .form-group { + width: 33.33%; + padding: 0 10px; } - - /* Profile form submit button */ .profile-form .submit-btn { - background-color: #333; - color: white; - border: none; - border-radius: 5px; - padding: 10px 20px; - cursor: pointer; - } - - /* Profile form submit button on hover */ - .profile-form .submit-btn:hover { - background-color: #555; - } - - /* Error message styles */ - .error-message { - color: red; - margin-top: 5px; - } - - /* Success message styles */ - .success-message { - color: green; - margin-top: 5px; + width: auto; } - \ No newline at end of file +} diff --git a/src/css/register.css b/src/css/register.css index 6fa4951..d86360f 100644 --- a/src/css/register.css +++ b/src/css/register.css @@ -2,92 +2,110 @@ /* Container styling */ .registration-container { - max-width: 400px; - margin: 0 auto; - padding: 40px; - background-color: #ffffff; - border-radius: 8px; - box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1); - } - - /* Form styling */ - .form-group { - margin-bottom: 20px; - } - - label { - display: block; - font-weight: bold; - margin-bottom: 8px; - color: #333; + max-width: 400px; + margin: 0 auto; + padding: 40px; + background-color: #ffffff; + border-radius: 8px; + box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1); +} + +/* Form styling */ +.form-group { + margin-bottom: 20px; +} + +label { + display: block; + font-weight: bold; + margin-bottom: 8px; + color: #333; +} + +input[type="text"], +input[type="email"], +input[type="password"] { + width: 100%; + padding: 12px; + border: 1px solid #ccc; + border-radius: 4px; + font-size: 16px; + transition: border-color 0.3s ease-in-out; +} + +input[type="text"]:focus, +input[type="email"]:focus, +input[type="password"]:focus { + border-color: #007bff; +} + +button[type="submit"] { + background-color: #007bff; + color: #fff; + border: none; + border-radius: 4px; + padding: 12px 20px; + cursor: pointer; + font-size: 18px; + transition: background-color 0.3s ease-in-out; +} + +button[type="submit"]:hover { + background-color: #0056b3; +} + +/* Error message styling */ +.alert { + padding: 10px; + margin-bottom: 20px; + border-radius: 4px; + color: #721c24; + background-color: #f8d7da; + border: 1px solid #f5c6cb; +} + +/* Link styling */ +a { + color: #007bff; + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +/* Responsive styling */ + +/* Mobile screens */ +@media screen and (max-width: 600px) { + .registration-container { + padding: 20px; } - + input[type="text"], input[type="email"], input[type="password"] { - width: 100%; - padding: 12px; - border: 1px solid #ccc; - border-radius: 4px; - font-size: 16px; - transition: border-color 0.3s ease-in-out; - } - - input[type="text"]:focus, - input[type="email"]:focus, - input[type="password"]:focus { - border-color: #007bff; + font-size: 14px; } - + button[type="submit"] { - background-color: #007bff; - color: #fff; - border: none; - border-radius: 4px; - padding: 12px 20px; - cursor: pointer; - font-size: 18px; - transition: background-color 0.3s ease-in-out; - } - - button[type="submit"]:hover { - background-color: #0056b3; - } - - /* Error message styling */ - .alert { - padding: 10px; - margin-bottom: 20px; - border-radius: 4px; - color: #721c24; - background-color: #f8d7da; - border: 1px solid #f5c6cb; + font-size: 16px; } - - /* Link styling */ - a { - color: #007bff; - text-decoration: none; +} + +/* Tablet screens */ +@media screen and (min-width: 601px) and (max-width: 1024px) { + .registration-container { + max-width: 600px; } - a:hover { - text-decoration: underline; + input[type="text"], + input[type="email"], + input[type="password"] { + font-size: 15px; } - - /* Responsive styling */ - @media screen and (max-width: 600px) { - .registration-container { - padding: 20px; - } - - input[type="text"], - input[type="email"], - input[type="password"] { - font-size: 14px; - } - - button[type="submit"] { - font-size: 16px; - } + + button[type="submit"] { + font-size: 17px; } - \ No newline at end of file +} From 3f55ee5ed66af2314d6e00b2e41b3fbf3f4a2924 Mon Sep 17 00:00:00 2001 From: Dharansh Neema Date: Tue, 3 Oct 2023 02:00:06 +0530 Subject: [PATCH 2/7] Refactored app.js and created config file --- src/app.js | 150 ++++++++++++++++------------------- src/config/dbconfig.js | 17 ++++ src/config/passportConfig.js | 41 ++++++++++ 3 files changed, 125 insertions(+), 83 deletions(-) create mode 100644 src/config/dbconfig.js create mode 100644 src/config/passportConfig.js diff --git a/src/app.js b/src/app.js index 04a14d0..b1ceafd 100644 --- a/src/app.js +++ b/src/app.js @@ -12,7 +12,12 @@ const csrf = require("csurf"); const cookieParser = require("cookie-parser"); const mongoSanitize = require("express-mongo-sanitize"); const dotenv = require("dotenv"); +const path = require("path"); + +const dbConfig = require("./config/dbconfig"); dotenv.config(); +// Connect to MongoDB using the configuration +dbConfig(); const courseModel = require("./db/courseDB"); @@ -27,8 +32,9 @@ const limiter = rateLimit({ message: "Too many requests from this IP, please try again later.", }); +//Views folder should be accessible from anywhere.. +app.set("views", path.join(__dirname, "views")); app.set("view engine", "ejs"); -app.set("views", "src/views"); app.use(express.urlencoded({ extended: true })); app.use(morgan("dev")); @@ -36,58 +42,20 @@ app.use(mongoSanitize()); const addCSRF = require("./middlewares/addCSRF"); -// Connect to MongoDB using the configuration -mongoose - .connect(process.env.MONGODB_URL, { - useNewUrlParser: true, - useUnifiedTopology: true, - }) - .then(() => { - console.log("Connected to MongoDB"); - // Start your application logic here - }) - .catch((err) => { - console.error("Error connecting to MongoDB:", err); - process.exit(1); - }); - -passport.use( - new LocalStrategy(async (username, password, done) => { - try { - const user = await User.findOne({ username: username }); - if (!user) return done(null, false, { message: "Incorrect username." }); - const passwordMatch = await bcrypt.compare(password, user.password); - if (!passwordMatch) - return done(null, false, { message: "Incorrect password." }); - - return done(null, user); - } catch (err) { - return done(err); - } - }) -); - -passport.serializeUser((user, done) => { - done(null, user.id); -}); - -passport.deserializeUser((id, done) => { - User.findById(id) - .then((user) => { - done(null, user); - }) - .catch((err) => { - done(err); - }); -}); - +//Regular middleware app.use(cookieParser()); //app.use(csrf()); //app.use(addCSRF) app.use( - session({ secret: process.env.SECRET_KEY, resave: false, saveUninitialized: true }) + session({ + secret: process.env.SECRET_KEY, + resave: false, + saveUninitialized: true, + }) ); app.use(flash()); +// Initialize Passport and session middleware +require("./config/passportConfig"); app.use(passport.initialize()); app.use(passport.session()); //changes @@ -98,7 +66,10 @@ app.get("/login", limiter, csrfProtection, (req, res) => { if (req.isAuthenticated()) { return res.redirect("/"); } else { - res.render("login", { messages: req.flash("error"), csrfToken: req.csrfToken() }); // Pass flash messages to the template + res.render("login", { + messages: req.flash("error"), + csrfToken: req.csrfToken(), + }); // Pass flash messages to the template } }); @@ -124,12 +95,12 @@ app.post("/login", limiter, csrfProtection, (req, res, next) => { })(req, res, next); }); -app.get('/logout', limiter, (req, res) => { +app.get("/logout", limiter, (req, res) => { req.session.destroy(function (err) { if (err) { console.error("Error during logout:", err); } else { - res.redirect('/login'); + res.redirect("/login"); } }); }); @@ -141,8 +112,11 @@ app.get("/", isAuthenticated, (req, res) => { app.get("/register", (req, res) => { if (req.isAuthenticated()) return res.redirect("/"); - console.log(req.csrfToken()) - res.render("register", { messages: req.flash("error"), csrfToken: req.csrfToken() }); + console.log(req.csrfToken()); + res.render("register", { + messages: req.flash("error"), + csrfToken: req.csrfToken(), + }); }); app.post("/register", limiter, csrfProtection, async (req, res) => { @@ -177,7 +151,7 @@ app.post("/register", limiter, csrfProtection, async (req, res) => { username: username, email: email, password: hashedPassword, - fullName + fullName, // Additional user profile fields can be added here }); @@ -192,44 +166,54 @@ app.post("/register", limiter, csrfProtection, async (req, res) => { } }); -app.get('/profile', isAuthenticated, async (req, res) => { - res.render('profile', { user: req.user, messages: req.flash(), csrfToken: req.csrfToken() }); +app.get("/profile", isAuthenticated, async (req, res) => { + res.render("profile", { + user: req.user, + messages: req.flash(), + csrfToken: req.csrfToken(), + }); }); -app.post('/profile', limiter, isAuthenticated, csrfProtection, async (req, res) => { - /*if (!req.body._csrf || req.body._csrf !== req.csrfToken()) { +app.post( + "/profile", + limiter, + isAuthenticated, + csrfProtection, + async (req, res) => { + /*if (!req.body._csrf || req.body._csrf !== req.csrfToken()) { return res.status(403).send("CSRF token validation failed."); }*/ - const { fullName, avatarUrl, bio, location, website } = req.body; - - try { - // Find the user by their ID (you need to have the user ID stored in the session) - const userId = req.user._id; // Assuming you have a user object in the session - const user = await User.findById(userId); - - if (!user) { - // Handle the case where the user is not found - return res.status(404).send("User not found."); - } + const { fullName, avatarUrl, bio, location, website } = req.body; - // Update the user's profile fields - user.fullName = fullName; - user.avatarUrl = avatarUrl; - user.bio = bio; - user.location = location; - user.website = website; + try { + // Find the user by their ID (you need to have the user ID stored in the session) + const userId = req.user._id; // Assuming you have a user object in the session + const user = await User.findById(userId); - // Save the updated user profile - await user.save(); + if (!user) { + // Handle the case where the user is not found + return res.status(404).send("User not found."); + } - // Redirect to the user's profile page or any other desired page - return res.redirect("/profile"); - } catch (error) { - console.error("Error updating profile:", error); - // Handle the error, display an error message, or redirect to an error page - return res.status(500).send("Error updating profile."); + // Update the user's profile fields + user.fullName = fullName; + user.avatarUrl = avatarUrl; + user.bio = bio; + user.location = location; + user.website = website; + + // Save the updated user profile + await user.save(); + + // Redirect to the user's profile page or any other desired page + return res.redirect("/profile"); + } catch (error) { + console.error("Error updating profile:", error); + // Handle the error, display an error message, or redirect to an error page + return res.status(500).send("Error updating profile."); + } } -}); +); app.use("/courses", limiter, isAuthenticated, async function (req, res) { const courses = await courseModel.find(); diff --git a/src/config/dbconfig.js b/src/config/dbconfig.js new file mode 100644 index 0000000..6ac912a --- /dev/null +++ b/src/config/dbconfig.js @@ -0,0 +1,17 @@ +const mongoose = require("mongoose"); +function dbConfig() { + mongoose + .connect(process.env.MONGODB_URL, { + useNewUrlParser: true, + useUnifiedTopology: true, + }) + .then(() => { + console.log("Connected to MongoDB"); + // Start your application logic here + }) + .catch((err) => { + console.error("Error connecting to MongoDB:", err); + process.exit(1); + }); +} +module.exports = dbConfig; diff --git a/src/config/passportConfig.js b/src/config/passportConfig.js new file mode 100644 index 0000000..12d04ee --- /dev/null +++ b/src/config/passportConfig.js @@ -0,0 +1,41 @@ +const passport = require("passport"); +const LocalStrategy = require("passport-local").Strategy; +const bcrypt = require("bcrypt"); + +const User = require("../db/User"); + +passport.use( + new LocalStrategy(async (username, password, done) => { + try { + const user = await User.findOne({ username: username }); + + if (!user) { + return done(null, false, { message: "Incorrect username." }); + } + + const passwordMatch = await bcrypt.compare(password, user.password); + + if (!passwordMatch) { + return done(null, false, { message: "Incorrect password." }); + } + + return done(null, user); + } catch (err) { + return done(err); + } + }) +); + +passport.serializeUser((user, done) => { + done(null, user.id); +}); + +passport.deserializeUser((id, done) => { + User.findById(id) + .then((user) => { + done(null, user); + }) + .catch((err) => { + done(err); + }); +}); From dfaeffb9e329d530af6ca77067d53f1189443876 Mon Sep 17 00:00:00 2001 From: Dharansh Neema Date: Tue, 3 Oct 2023 02:33:15 +0530 Subject: [PATCH 3/7] Added readme file with set-up instruction --- src/readme.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/readme.md diff --git a/src/readme.md b/src/readme.md new file mode 100644 index 0000000..f429e0a --- /dev/null +++ b/src/readme.md @@ -0,0 +1,33 @@ +# Welcome to Course manager + +Want to contribute? Well your most welcome here is an Set-up instruction to help you out. + +## Setup Instructions + +### 1. Clone the repository: + +```git clone https://github.com/Artlfmj/course-manager.git + + cd course-manager +``` + +### 2. Install dependencies + +`npm install` + +### 3. Set-up .env + +`touch .env` +or make file named as .env and assign this varaibles in that + +``` +MONGODB_URL=mongodb://localhost:27017/ +SECRET_KEY= +``` + +### 4. Start the application + +`npm run` + +or +`node app.js` From 51c16a53aaad0b7d889c5dd01ad306dff9db3921 Mon Sep 17 00:00:00 2001 From: Dharansh Neema Date: Tue, 3 Oct 2023 02:35:27 +0530 Subject: [PATCH 4/7] Edited readme.md --- src/readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/readme.md b/src/readme.md index f429e0a..82f5e88 100644 --- a/src/readme.md +++ b/src/readme.md @@ -6,8 +6,8 @@ Want to contribute? Well your most welcome here is an Set-up instruction to help ### 1. Clone the repository: -```git clone https://github.com/Artlfmj/course-manager.git - +``` + git clone https://github.com/Artlfmj/course-manager.git cd course-manager ``` From 738a2b141be4b2652632d3e76664331dd27b7415 Mon Sep 17 00:00:00 2001 From: Dharansh Neema Date: Tue, 3 Oct 2023 11:05:51 +0530 Subject: [PATCH 5/7] Deleted readme file as requested. --- src/readme.md | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 src/readme.md diff --git a/src/readme.md b/src/readme.md deleted file mode 100644 index 82f5e88..0000000 --- a/src/readme.md +++ /dev/null @@ -1,33 +0,0 @@ -# Welcome to Course manager - -Want to contribute? Well your most welcome here is an Set-up instruction to help you out. - -## Setup Instructions - -### 1. Clone the repository: - -``` - git clone https://github.com/Artlfmj/course-manager.git - cd course-manager -``` - -### 2. Install dependencies - -`npm install` - -### 3. Set-up .env - -`touch .env` -or make file named as .env and assign this varaibles in that - -``` -MONGODB_URL=mongodb://localhost:27017/ -SECRET_KEY= -``` - -### 4. Start the application - -`npm run` - -or -`node app.js` From 8cf4108247fa0fdfb2ed9d71e568b56b96919370 Mon Sep 17 00:00:00 2001 From: Ankush Date: Tue, 3 Oct 2023 12:24:49 +0530 Subject: [PATCH 6/7] added nodemon package and added script inside the package.json so dev can see the changes --- package-lock.json | 282 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 + 2 files changed, 284 insertions(+) diff --git a/package-lock.json b/package-lock.json index bd3ca05..1aced15 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "mongodb": "^6.1.0", "mongoose": "^7.5.3", "morgan": "^1.10.0", + "nodemon": "^3.0.1", "passport": "^0.6.0", "passport-local": "^1.0.0", "passport-local-mongoose": "^8.0.0" @@ -144,6 +145,18 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/aproba": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", @@ -205,6 +218,14 @@ "node": ">= 10.0.0" } }, + "node_modules/binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "engines": { + "node": ">=8" + } + }, "node_modules/body-parser": { "version": "1.20.1", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", @@ -237,6 +258,17 @@ "concat-map": "0.0.1" } }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/bson": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/bson/-/bson-6.1.0.tgz", @@ -280,6 +312,32 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, "node_modules/chownr": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", @@ -669,6 +727,17 @@ "node": ">=10" } }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/finalhandler": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", @@ -729,6 +798,19 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -791,6 +873,17 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -896,6 +989,11 @@ "node": ">=0.10.0" } }, + "node_modules/ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==" + }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -923,6 +1021,25 @@ "node": ">= 0.10" } }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -931,6 +1048,25 @@ "node": ">=8" } }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "engines": { + "node": ">=0.12.0" + } + }, "node_modules/jake": { "version": "10.8.7", "resolved": "https://registry.npmjs.org/jake/-/jake-10.8.7.tgz", @@ -1348,6 +1484,65 @@ "webidl-conversions": "^3.0.0" } }, + "node_modules/nodemon": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.0.1.tgz", + "integrity": "sha512-g9AZ7HmkhQkqXkRc20w+ZfQ73cHLbE8hnPbtaFbFtCumZsjyMhKk9LajQ07U5Ux28lvFjZ5X7HvWR1xzU8jHVw==", + "dependencies": { + "chokidar": "^3.5.2", + "debug": "^3.2.7", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.1.2", + "pstree.remy": "^1.1.8", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "bin": { + "nodemon": "bin/nodemon.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nodemon" + } + }, + "node_modules/nodemon/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/nodemon/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "engines": { + "node": ">=4" + } + }, + "node_modules/nodemon/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/nodemon/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/nopt": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz", @@ -1362,6 +1557,14 @@ "node": ">=6" } }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/npmlog": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-5.0.1.tgz", @@ -1491,6 +1694,17 @@ "resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz", "integrity": "sha512-KG8UEiEVkR3wGEb4m5yZkVCzigAD+cVEJck2CzYZO37ZGJfctvVptVO192MwrtPhzONn6go8ylnOdMhKqi4nfg==" }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", @@ -1503,6 +1717,11 @@ "node": ">= 0.10" } }, + "node_modules/pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==" + }, "node_modules/punycode": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", @@ -1568,6 +1787,17 @@ "node": ">= 6" } }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, "node_modules/rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -1705,6 +1935,17 @@ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" }, + "node_modules/simple-update-notifier": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/smart-buffer": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", @@ -1802,6 +2043,17 @@ "node": ">=10" } }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, "node_modules/toidentifier": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", @@ -1810,6 +2062,31 @@ "node": ">=0.6" } }, + "node_modules/touch": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", + "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", + "dependencies": { + "nopt": "~1.0.10" + }, + "bin": { + "nodetouch": "bin/nodetouch.js" + } + }, + "node_modules/touch/node_modules/nopt": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", + "integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==", + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": "*" + } + }, "node_modules/tr46": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz", @@ -1852,6 +2129,11 @@ "node": ">= 0.8" } }, + "node_modules/undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==" + }, "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", diff --git a/package.json b/package.json index 12957f8..cedbe16 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "mongodb": "^6.1.0", "mongoose": "^7.5.3", "morgan": "^1.10.0", + "nodemon": "^3.0.1", "passport": "^0.6.0", "passport-local": "^1.0.0", "passport-local-mongoose": "^8.0.0" @@ -23,6 +24,7 @@ "main": "src/app.js", "scripts": { "start": "node src/app.js", + "dev": "nodemon src/app.js", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { From aa47c6a5c3e7fed83445eff32fe3755ac785a389 Mon Sep 17 00:00:00 2001 From: Ankush Date: Tue, 3 Oct 2023 12:43:38 +0530 Subject: [PATCH 7/7] Added Setup.md file --- setup.md | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 setup.md diff --git a/setup.md b/setup.md new file mode 100644 index 0000000..8d372c5 --- /dev/null +++ b/setup.md @@ -0,0 +1,49 @@ +# Project Setup + +This guide will help you set up the project on your local machine. + +## Step 1: Install Dependencies + +First, you need to install the project dependencies. Run the following command in your terminal: + +```bash +npm install +``` + +## Step 2: Set Up Environment Variables + +There is an example.env.txt file in the project root. Create a new file named .env in the same location and copy the contents of example.env.txt into it. + +In the .env file, you will find a placeholder for MONGODB_URL credential. Replace it with your actual credentials. + +If you’re running MongoDB locally, your database link will look something like this: + +```bash +mongodb://localhost:27017/mydatabase +``` + +If you’re using a cloud database service like MongoDB Atlas, your database link will be provided by the service.which will look something like this: + +- replace the password with actual password + +```bash +mongodb+srv://databasename:@something.banc821.mongodb.net/ +``` + +## Step 3: Start the Server + +To start the server, run the following command: + +```bash +npm run dev +``` + +Now, your server should be up and running! + +## Step 4: Access the Server + +You can access the server by typing http://localhost: in your browser, where is the port number on which your server is running. the default port is 3000: + +```bash + http://localhost:3000 +```