- Running the API Server
- Running the Tests
- API Documentation
- Using Fake Values
- Pushing the Data to Algolia
- Sending Emails
- Queue Manager
- Adonis Framework
- Copy the
.env.example
file to.env
and update all of the environment variables correctly. - Make sure you have a MySQL database server (feel free to use docker or whatever method you prefer) up and running and update the
DB_HOST
,DB_PORT
,DB_USER
andDB_PASSWORD
environment variables. - Run the migrations in order to create the tables:
npm run migration:run
- Fill the database with the default values:
If you prefer, you can use fake values in order to fill your application database.
Do not run the default seed command if you prefer to use fake values
npm run seed:default
- Make sure the
APP_KEY
variable has been filled in the.env
file (you can runnpx adonis key:generate
if you want). - Start the server:
npm start
(npm run dev
for develop mode). - The API server will be available at
http://127.0.0.1:3333
.
After updating the environment variables in the .env.testing
file, run:
npm run test
If you want to take a look at the code coverage, run:
npm run coverage
The API server will use DB_USER
and DB_PASSWORD
values set in the .env
file in order to connect to the testing database server.
This project has been documented by using apiDoc. Use the following script to generate/update the documentation:
npm run apidoc
After generating the documentation files, you can start the API server and visit http://localhost:3333/docs
to see the documentation.
If you ran the default seed script before, you will receive an error when running the following script. Reset the database before running this script
You can fill the database with fake values for testing purposes:
- Set the Algolia config.
- Run the following script:
npm run seed
In order to use Algolia, you should create an account on the Algolia website (there is a free account option) and set the ALGOLIA_APP_ID
(Application ID) and ALGOLIA_ADMIN_KEY
(Admin API) variables.
The algolia index name prefix is searchable
by default, but you can replace it by setting a new ALGOLIA_INDEX_PREFIX
variable value. Remember to update the index name prefix in web package too. Otherwise it will fail to search.
Before running the API server, you should push all of the database data to algolia by running the following command:
npm run algolia:index
In order to send emails, you should update the SMTP information by setting the following environment variables:
SMTP_PORT=
SMTP_HOST=
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_FROM=noreply@plataformasabia.com.br
Feel free to use any email service that supports SMTP protocol (e.g.: sendgrid, mailgun or even gmail).
This project uses Bull for queue manager. Make sure you have a Redis server (feel free to use docker or whatever method you prefer) up and running. Bull will by default try to connect to a Redis server running on localhost:6379. For development purposes it is possible monitoriing the queue using Bull Board dashboard. In http://localhost:9999
.
In order to use Google Analytics integration, you should update the following environment variables:
GA_CLIENT_EMAIL=
GA_PRIVATE_KEY=
GA_VIEW_ID_SITE=
GA_VIEW_ID_BLOG=
The GA_CLIENT_EMAIL
and GA_PRIVATE_KEY
keys are used for Google Analytics authentication. They can be found in the Google API Console in the credentials menu.
GA_CLIENT_EMAIL
is a Google service account for the Google project of the platform you knew.GA_PRIVATE_KEY
is found in the downloaded file.json
.GA_VIEW_ID_SITE
andGA_VIEW_ID_BLOG
are a view ID. They are found on the Google Analytics website, in the preview section.
This project was bootstrapped by using the Adonis Framework.