Create MongoDB account.
Create Database cluster.
Create User collection.
In the "Database Deployments" overview, press on "Connect".
In the above example, "user" is username who has an access to your database cluster, and password is theirs password.
Save password of that user and their username, you will use it in your connection string.
Environment variable names should be the same, the only parts that change are values.
Aside from environment variables for MongoDB we also utilize several other variables that should be initialized in .env file.
PORT
should be defined with a port number for the server
NODE_ENV
if dev
is assigned, server will use LOCAL_MONGODB_CONNECTION_STRING
, otherwise
MONGODB_CONNECTION_STRING
is chosen for database connection.
MONGODB_CONNECTION_STRING
defines connection string to the MongoDB account
LOCAL_MONGODB_CONNECTION_STRING
defines connection string to the local MongoDB account
PRIVATE_KEY_FOR_USER_TOKEN
shoud be defined with the random string that will act as unique private key for bcrypt encryption
SPOONACULAR_API_KEY
should be defined with a key to spoonacular api
SPOONACULAR_HOST="spoonacular-recipe-food-nutrition-v1.p.rapidapi.com"
SPOONACULAR_INGREDIENTS_BASE_URL="https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/food/ingredients"
SPOONACULAR_GROCERY_PRODUCT_BASE_URL="https://api.spoonacular.com/food/products"
SPOONACULAR_RECIPE_BASE_URL="https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes"
To run server install latest npm and run npm install
. All required packages will be installed automatically. Now, go to the project directory and run npm start
.
To run tests use npm run test
or npm test
.
https://app.swaggerhub.com/apis/mplekunov/Smart-Chef-API/1.0.0