Create a Full Stack Mern Social Media Application - Part 2

ayushdeveloper

Ayush Deb

Posted on October 14, 2024

Create a Full Stack Mern Social Media Application - Part 2

So it looks like this series is going to be long if I have to put every single detail here. But if it can help somebody I am up for it .

1. Configure the file storage on your index.js

FILE STORAGE

const storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, "public/assets");
},
filename: function (req, file, cb) {
cb(null, file.originalname);
},
});
const upload = multer({ storage });

  • Stores files in the "public/assets" folder.
  • Keeps the original file name when saving the uploaded file.
  • Multer is configured to handle these uploads in your app.

2. Configure MongoDB Atlas

Create and configure a MongoDB Atlas server.

Create a .env file and put the mongodb url along with your password inside the url.

Put the port number

3. Create the Auth.js file

  1. Use brcypt to hash the password and create the user with all credentials and details.
  2. Use jsonwebtoken or 'jwt' for authentication
  3. import user module from the userSchema made using mongoose.
💖 💪 🙅 🚩
ayushdeveloper
Ayush Deb

Posted on October 14, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related