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
- Use brcypt to hash the password and create the user with all credentials and details.
- Use jsonwebtoken or 'jwt' for authentication
- import user module from the userSchema made using mongoose.
This content originally appeared on DEV Community and was authored by Ayush Deb
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/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.