API Setup

Here, it gives information about how to add credentials to the project, installing dependencies, and information of all environment variables.

As you can see above images we have API Directory that has all the rest API we build to run CMS.

ADD CREDENTIAL TO PROJECT

You need to add .env file on the project directory and you need to create and add all required variable on .env file

Let me explain you the uses of all the credentials that you need to add in .env

# MongoDB url for staging and production
MONGO_DB_URL_STAGING=<mongo_db_url_development>
MONGO_DB_URL_PRODUCTION=<mongo_db_url_production>
# Secret key for JWT token
SECRET=<32_digits_random_string>
# Stripe secret key for card payment
STRIPE_SECRET_KEY=<stripe_secret_key>
# Imagekit for image upload
IMAGEKIT_URL=https://ik.imagekit.io/<imagekit_id>/
IMAGEKIT_PUBLIC_KEY=<imagekit_public_key>
IMAGEKIT_PRIVATE_KEY=<imagekit_private_key>
# Onesignal for user app
ONE_SIGNAL_APP_ID_USER=<onesignal_app_id>
ONE_SIGNAL_SECRET_KEY_USER=<onesignal_secret_key>
# Onesignal for delivery app
ONE_SIGNAL_APP_ID_DELIVERY=<onesignal_app_id>
ONE_SIGNAL_SECRET_KEY_DELIVERY=<onesignal_secret_key>
# Api deployed url for email verification
API_URL_STAGING=<api_deployed_url_development>
API_URL_PRODUCTION=<api_deployed_url_production>
# if true api will use Sendinblue for SMS & Emails
# else api will use Sendgrid for Emails and Twilio for SMS
USE_SENDINBLUE=true
# Country Code
COUNTRY_CODE=<country_code>
# Twilio for sending SMS
TWILIO_ACCOUNT_SID=<twilio_account_sid>
TWILIO_AUTH_TOKEN=<twilio_authentication_token>
TWILIO_SID=<twilio_sid>
# Sendgrid for email sending
SENDGRID_KEY=<sendgrid_api_key>
SENDGRID_FROM=<sendgrid_from_email>
# Sendinblue for sending emails and SMS
SENDINBLUE_HOST_NAME=<sendinblue_host_name>
SENDINBLUE_USER=<sendinblue_user>
SENDINBLUE_PASSWORD=<sendinblue_password>
SENDINBLUE_URL_FOR_OTP=<sendinblue_url>
SENDINBLUE_API_KEY_FOR_OTP=<sendinblue_api_key_for_otp>
PREDIFINED=true

Installing dependencies

just run following command to install all required dependencies.

npm install

Information of all Environment variables

MongoDB URL MongoDB we use for all the data storage and above .env file, you can see we have 2 MongoDB link. development and production. You can keep both database different or if want to keep both same can keep MongoDB URL same in both Environments.

SECRET Add 32 digit random string which will use for JWT secret key for validation of the token

STRIPE SECRET KEY We using stripe as payment gateway and if you want to use stripe, create a secret key from your stripe account and add in this variable. If not, leave as blank.

IMAGE KIT We use image kit for images storage as it provides more flexibility with images and it can optimize in the fly to keep our app performance hight. You need public and private key for this. Once you create an account on image kit get both the key and image kit id.

One Signal It's one of the leaders in Push notification service provider and you can use their services in the future for marketing and promotional PUSH as well. Once you create an account with one signal get App ID and secret key. Create two separate App ID and secret key. one for the user app and another for the delivery app. You can use one for both apps.

API URL You need to set the API deployed URL for email verification. It should be same on which domain or IP, API is deployed

SENDGRID Sendgrid used to trigger any email in-app. You can integrate this with other Email service providers like SES etc but that required some basic changes in your backend nodeJS code. Once you create the SENDGRID account get an API key and add it above. In SENDGRID_FROM add email id from which you want to send an email to your customer. e.g. info@yourdomainname.com TWILIO We use twilio to send OTP to mobile number while registration. You need to create account on twilio website and from their dashboard you will get required credentials put it on create .env file.

SENDINBLUE We use Sendinblue as an alternative to Twilio and Sendgrid to send messages and emails. so you will need any one of them either twilio and sendgrid or just sendinblue.

SETUP DEMO DATA

To setup demo data in your product, you need to run following command on project directory. npx ts-node mongodb-seeding.ts

After running this, it will ask you

Enter the Mongo DB connection uri string: you need to pass here your MongoDB URL in which database you want to reset data. again it will ask you

Is it for production? (production/staging): you need to just press enter here.

After that, it will reset data in your MongoDB database as our demo.