- Node.js
- Express
- MongoDB
# with npm
npm install
npm install dotenv --save-dev
Add the following code the server.js
file.
require('dotenv').config()
Create a .env
file in the root directory of project. Add
environment variables specified below.
MONGO_PASS= mongodb-password
CRYPTO_PASSWORD=crypto-password
CRYPTO_SALT=salt-used-in-cyrpto
JWT_SECRETKEY=jwt-secret-key
NODEMAILER_EMAILID=your-mail-id
NODEMAILER_PASSWORD=your-mail-password
PORT=3000
DEV=1
Replace the MONGO_URL
with 'mongodb://localhost:27017'
const MONGO_URL = 'mongodb://localhost:27017';
The given url in the code is of MongoDB Atlas cloud database.
Follow the link create an Atlas Account-
- MongoDBAtlas - Getting Started with MongoDB Atlas