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({
de…


This content originally appeared on DEV Community and was authored by Ayush Deb

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.


This content originally appeared on DEV Community and was authored by Ayush Deb


Print Share Comment Cite Upload Translate Updates
APA

Ayush Deb | Sciencx (2024-10-14T21:43:24+00:00) Create a Full Stack Mern Social Media Application – Part 2. Retrieved from https://www.scien.cx/2024/10/14/create-a-full-stack-mern-social-media-application-part-2/

MLA
" » Create a Full Stack Mern Social Media Application – Part 2." Ayush Deb | Sciencx - Monday October 14, 2024, https://www.scien.cx/2024/10/14/create-a-full-stack-mern-social-media-application-part-2/
HARVARD
Ayush Deb | Sciencx Monday October 14, 2024 » Create a Full Stack Mern Social Media Application – Part 2., viewed ,<https://www.scien.cx/2024/10/14/create-a-full-stack-mern-social-media-application-part-2/>
VANCOUVER
Ayush Deb | Sciencx - » Create a Full Stack Mern Social Media Application – Part 2. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/10/14/create-a-full-stack-mern-social-media-application-part-2/
CHICAGO
" » Create a Full Stack Mern Social Media Application – Part 2." Ayush Deb | Sciencx - Accessed . https://www.scien.cx/2024/10/14/create-a-full-stack-mern-social-media-application-part-2/
IEEE
" » Create a Full Stack Mern Social Media Application – Part 2." Ayush Deb | Sciencx [Online]. Available: https://www.scien.cx/2024/10/14/create-a-full-stack-mern-social-media-application-part-2/. [Accessed: ]
rf:citation
» Create a Full Stack Mern Social Media Application – Part 2 | Ayush Deb | Sciencx | https://www.scien.cx/2024/10/14/create-a-full-stack-mern-social-media-application-part-2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.