Skip to content

Jean-Dv/PortfolioTemplateFullStack

Repository files navigation

Getting Started with Portfolio Full Stack

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:

Instalation and Usage

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)

npm run dev

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.

npm run lint

Run the ts-standard linter to look at errors in the code

npm run build

Convert all the .ts files to .js, this will allow us to upload the project to production through heroku. (It will be explained later)

npm run start

Run the project in production mode by default choose the file found in ./build/bin/www.js.

npm run update:repos

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)

Usage

Create MONGO_URI

To create the Mongo Atlas database follow this tutorial.

Create GITHUB_API_TOKEN

To create the github token you have to follow this tutorial.
But select the following scopes. Scopes

Modified environment variables

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)"

Deployment

1. Create your account in Heroku

2. Create new app

Enter the following link so you can see your Heroku apps and you can also create one (https://dashboard.heroku.com/apps) Create New App

3. Configure your heroku app with your github

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 Screen onnect github You will only have to search for your repository or the fork to ours and click connect

4. Configure cron job

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 Screen in resources Screen in submit order from

5. Add cron job in heroku scheduler

To add it you will have to click on the link that appears. (Heroku Scheduler)
Heroku Scheduler resources

  • Create job
    Heroku Scheduler
  • Job editor
    Heroku Job Editor

Just save job and ready we have configured our backend