DEV Community

Cover image for Create a Full Stack Mern Social Media Application - Part 2
Ayush Deb
Ayush Deb

Posted on

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.

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay