Skip to content

rafaelcascalho/be-the-hero-backend

Repository files navigation

Be the hero - API (Backend)

This is my personal implementation of the app be-the-hero from the omnistack 11 make by rocketseat.

Jest test coverage reports badges.

Statements Branches Functions Lines
Statements Branches Functions Lines

📚 Documentation 📚

Full Project

Here is a link to the project docs.

API

Here is a link to the api docs.

Prerequisites

⚠️ Required ⚠️

Node current LTS To install node and npm just download it here or follow this tutorial. To check the version run the command

$ node -v
v12.16.1

Yarn version 1.22.4 or npm (latest is advised) To install yarn just follow their docs To check the version run the command

$ yarn -v
1.22.4

Postgres version 12.2

Optional :glasses:

Docker and docker-compose

$ docker -v
Docker version 19.03.8, build afacb8b7f0

$ docker-compose -v
docker-compose version 1.25.4, build 8d51620a

🚧 Instalation 🚧

  1. Install yarn or npm
  2. Install the postgres dbms in your machine OR docker (composer is also optional)

Optional :glasses:

If you want to execute the knex commands with a shorter command, just install the npx module globaly. So you'll be able to run

$ npx knex command

Instead of

$ node_modules/.bin/knex command

🚀 Getting started 🚀

Set up and run :woman_running:

  1. Clone the repository and enter the repository directory

    $ git clone git@github.com:rafaelcascalho/be-the-hero-backend.git
    
    $ cd be-the-hero-backend
    
  2. Set up the database

    1. Run the postgres server
    2. Create a database with a name of your choice
    3. Create a .env file based on the .env.example file, and fill it with your database information
    4. Install the project dependencies with one of the commands below
    $ yarn install
    
  3. After that, we need to run the migrations with the following command

    $ node_modules/.bin/knex migrate:latest
    

    To check if your migrations were successfull just run the command

    $ node_modules/.bin/knex migrate:status
    

    And you should see and outcome like this one

    Found 2 Completed Migration file/files.
    20200328191618_create_ongs.js
    20200328192842_create_incidents.js
    No Pending Migration files Found.
    
  4. After that's done, you can just check if your development environment is running using the command

    $ yarn dev
    
  5. That's it! You're all set. :clinking_beer_mugs:

🌱 Seeding the database 🌱

To seed the database just run the command

$ yarn seed

🧪 Running the tests 🧪

To run the tests just use the command

$ yarn test

To run the tests and generate the coverage report run the command

$ yarn test:cov

🛡️ Checking dependencies 🛡️

To check if your dependecies have vulnerabilities just run the command

$ yarn sec

Case snyk finds any problems, you can run the wizard to manage them one by one with the command

$ yarn sec:wizard

To access the coverage reports generated, you can just access the /coverage/lcov-report/index.html from your browser, in the just generated folder coverage in the root of the project.

Deployment

This project is currently deployed at heroku PAAS. Case you're interested in doing the same just check out this tutorial.

🐳 IF you're using docker with docker-compose 🐳

This is an example of my docker-compose file

version: "3"

services:
psql:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: password
volumes: - ./data:/var/lib/postgresql/data
ports: - 5455:5432

Built With

About

Backend of the project be-the-hero made in omnistack11.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published