Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

vainapp/api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

back-end

This project is our main API that encompasses our website, app and administrative system.

Getting Started

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.

Prerequisites

Requirements for the software and other tools to build, test and push

Installing

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

CleanShot 2023-01-25 at 10 41 17

Running the tests

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 to localhost. For example, DB_HOST=redis should be DB_HOST=localhost.

REMEMBER TO CHANGE IT BACK BEFORE PUSHING A NEW COMMIT

Creating migrations

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>

Deployment

Our deployment is done automatically through our CI/CD infrastructure using GitHub Actions. The process is summarized in a few steps:

  1. When you open a PR, we run the Tests workflow (you can only merge a PR if the tests pass);
  2. 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.
  3. At the end of the Semantic release workflow, the Development deployment workflow is started, thus performing the deployment on our Digital Ocean servers;

Contributing

Understand how our Git flow works.

Developing new features

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
Loading

Fixing bugs

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

Versioning

We use Semantic Versioning for versioning. For the versions available, see the tags on this repository.