Giter Club home page Giter Club logo

auth-api's Introduction

๐Ÿ“ Description

Auth REST api using clean architecture

๐Ÿงฐ Installation

Prerequisites

Install yarn packages before continue

yarn

Ask other developers to share .env. For security reasons this file is not versioned.

Whenever a new environment variable is added, it must be also added to the .example.env file to keep everything up to date.

Setting up Docker

  • This is will make a new PostgreSQL running in the standard port 5432
  • Please shutdown any previous conflicting PostgreSQL instances before starting this
docker-compose up -d

Check the database is up

docker logs -f auth_pg

Check that you can log into a database with psql

docker exec -it auth_pg psql -U auth_user auth_db

View tables

\dt

Creating the initial database

Run initial migrations to set up initial database tables

yarn db:sync

Check the result of migrations using psql command-line tool

docker exec -it auth_pg psql -U auth_user auth_db
\d 'auth_db'

โŒจ Development

Running the app

yarn dev

๐Ÿงช Running tests per layer

Core layer

yarn test:core

# with code coverage
yarn test:core:coverage

After executing yarn test:core:coverage, the coverage/ folder will be generated with coverage details

Data layer

Creating tests database only integration tests are supported. Backend is spun up on a special database

Tests use their own database. To create it:

docker exec -it auth_pg psql -U auth_user -c "create database test" auth_db

Once the database is created, run the command below to test the data layer:

yarn test:data

Adding new migrations

You can generate migration files

  1. Update entity source code
  2. You have an up-to-date local development database
# creates a file under src/ports/mikroOrm/migrations/
yarn db:migration:create MigrationName

๐Ÿ“ Lint

Linting codebase

# getting lint issues
yarn lint

# fixing lint issues
yarn lint:fix

๐Ÿ“ฆ Building

Before building application to production, make sure environment variables are applied correctly

Building for production

yarn build

Running on production

yarn start

โœ… TODO

  • add JOI to validate data
  • add tests to ports layer
  • add mikroORM config for tests and disable logging in tests
  • add application logs
  • add way to detect if envs are loaded correctly
  • add swagger
  • add database health check
  • add stress tests
  • add CI
  • add CI security checks
  • add CD
  • add terraform or deploys with docker images
  • add localstack for local development
  • add husky pre-push hook

Observation: Some TODOS are spread across the code and need to be fixed ASAP

auth-api's People

Contributors

lucasmonstrox avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.