Auth REST api using clean architecture
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.
- 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
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'
yarn dev
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
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
You can generate migration files
- Update entity source code
- You have an up-to-date local development database
# creates a file under src/ports/mikroOrm/migrations/
yarn db:migration:create MigrationName
Linting codebase
# getting lint issues
yarn lint
# fixing lint issues
yarn lint:fix
Before building application to production, make sure environment variables are applied correctly
Building for production
yarn build
Running on production
yarn start
- 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