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.
Top comments (0)