This project is our main API that encompasses our website, app and administrative system.
These instructions will give you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on deploying the project on a live system.
Requirements for the software and other tools to build, test and push
A step by step series of examples that tell you how to get a development environment running
Install the dependencies
pnpm install
Start the databases with Docker
docker-compose -f docker-compose.local.yml up -d
Clone .env.example
to .development.env
and ask @joaopcm for AWS credentials
Run the database migrations
pnpm sequelize-cli db:migrate --url postgresql://postgres:postgres@localhost:5432/vain
Start the API
pnpm run server:dev
Start the queue
pnpm run queue:dev
After following these steps, you should be able to access the API at
http://localhost:3333
We use Jest in our tests. By default, we have only service tests, thus testing 100% of our business rules.
Stop local databases
docker-compose -f docker-compose.local.yml down
Start test databases
docker-compose -f docker-compose.test.yml up -d
Run the tests
npm run test
CleanShot.2023-01-25.at.11.01.19.mp4
🚧 Pay attention
If you're running the tests locally, you'll need to update the
.test.env
file replacing all the environment variables ending with_HOST
tolocalhost
. For example,DB_HOST=redis
should beDB_HOST=localhost
.REMEMBER TO CHANGE IT BACK BEFORE PUSHING A NEW COMMIT
We use Sequelize to manage our database migrations. To create a new migration, run the following command:
pnpm sequelize-cli migration:generate --name <migration name here>
Our deployment is done automatically through our CI/CD infrastructure using GitHub Actions. The process is summarized in a few steps:
- When you open a PR, we run the Tests workflow (you can only merge a PR if the tests pass);
- When merge a PR in the
develop
branch, the Semantic release workflow is executed together with the Tests workflow, thus generating a new release version. - At the end of the Semantic release workflow, the Development deployment workflow is started, thus performing the deployment on our Digital Ocean servers;
Understand how our Git flow works.
gitGraph
commit
branch develop
commit
branch issue-1
checkout issue-1
commit
commit
checkout develop
merge issue-1 tag:"v1.0.0"
checkout main
merge develop
checkout develop
branch issue-2
commit
commit
checkout develop
merge issue-2 tag:"v1.1.0"
checkout main
merge develop
gitGraph
commit
branch develop
checkout develop
commit
commit
checkout main
merge develop tag:"v1.1.1"
branch issue-3
checkout issue-3
commit id:"fix-commit"
checkout main
merge issue-3 tag:"v1.1.2"
checkout develop
cherry-pick id:"fix-commit"
We use Semantic Versioning for versioning. For the versions available, see the tags on this repository.