This project was created by Codest-x and Jean-Dev .
I Jean-Dv create the backend using Express, Node.Js (Runtime), and database with MongoDb:
Remember that this project is using ts-standard like linter and format code.
If you don't know about these libraries, you can watch this documentation:
Available Scripts
First you need to install all dependencies, you can that using yarn or npm:
You only need to type yarn or npm install
in console, and wait while the installation finish. Also you need to create several configuration files which are:
.env.development.local
.env.test.local
.env (production)
Runs the app in the development mode.
Open http://localhost:8080 to view it in the browser. If you put another port inside the .env.development.local
file change the port to localhost.
The page will reload if you make edits.
You will also see any lint errors in the console.
Run the ts-standard linter to look at errors in the code
Convert all the .ts
files to .js
, this will allow us to upload the project to production through heroku. (It will be explained later)
Run the project in production mode by default choose the file found in ./build/bin/www.js
.
This is a custom script so that we can update the database repositories that we set up in the Mongo Mongo Atlas database, it should be run as a cronjob. (I will explain later how to configure said cronjob in heroku)
To create the Mongo Atlas database follow this tutorial.
To create the github token you have to follow this tutorial.
But select the following scopes.
To use this backend you will have to place the following data in the aforementioned files:
PORT=8000
MONGO_URI="Uri what gives you mongo atlas"
SALTROUNDS=10
SECRETKEY="Create encrypted text at this url https://djecrety.ir/"
// Mailer leave the following data empty but place it in the file
MAIL_HOST=
MAIL_PORT=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REFRESH_TOKEN=
// Github
GITHUB_API_URL=https://api.github.com
GITHUB_API_TOKEN="Token created by github. (We already teach how)"
Enter the following link so you can see your Heroku apps and you can also create one (https://dashboard.heroku.com/apps)
After the previous step you are redirected to the configuration page of your application, you must click on Github (Connect to Github).
After accepting all Github permissions, the following screen will appear
You will only have to search for your repository or the fork to ours and click connect
To configure the aforementioned cron job you will only have to go to resources in the same configuration of your Heroku application, search for Heroku Scheduler and click on submit order from. As it's shown in the following
To add it you will have to click on the link that appears. (Heroku Scheduler)
Just save job and ready we have configured our backend