Eric Whale

Add mongoDB and it's config

const jwt = require("jsonwebtoken");
const bcrypt = require("bcryptjs");
// handles "exception" inside of async express routes
// (Used for mongoDB error in this project)
const asyncHandler = require("express-async-handler");
// @desc Signup new user
......@@ -29,7 +31,10 @@ const loginUser = asyncHandler(async (req, res) => {
// Send response
});
const getSelf = asyncHandler(async (req, res) => {});
module.exports = {
signupUser,
loginUser,
getSelf,
};
......
const colors = require("colors");
const mongoose = require("mongoose");
const colors = require("colors");
const connectDB = async () => {};
const connectDB = async () => {
try {
const conn = await mongoose.connect(process.env.MONGO_URI);
console.log(`MongoDB Connected: ${conn.connection.host}`.cyan.underline);
} catch (error) {
console.log(error);
process.exit(1);
}
};
module.exports = connectDB;
......
const mongoose = require("mongoose");
const userSchema = mongoose.Schema(
{
username: {
type: String,
required: [true, "Please add a username"],
},
email: {
type: String,
required: [true, "Please add a email"],
},
password: {
type: String,
required: [true, "Please add a password"],
},
},
{
timestamps: true,
}
);
const userModel = mongoose.model("User", userSchema);
module.exports = userModel;