Bloom Backend Services
This package is a NestJS application that provides a core set of backend services via REST API endpoints to apps using the Bloom Housing framework. Information is stored in a Postgres database, accessed via TypeORM.
OpenAPI Documentation
OpenAPI (fka Swagger) documentation is automatically generated by the server at http://localhost:3100/docs/
for a standard local development environment. A raw JSON version of the schema is also available at /docs-json/
, suitable for API client code generation or other code-based consumers.
Getting Started for Developers
The following steps should provide a working local environement for development purposes:
Setting up your local environment variables
Operational configuration the service is read from environment variables. Copy .env.template
to .env
and edit the settings specific to your development environment. Make sure the Database URL matches your Postgres configuration.
Installing Postgres
You can install Postgres using Homebrew with the following command: brew install postgresql
.
Setting up a Database
There are two databases used in this project: bloom
and bloom_test
. First is used every time you are starting a project with yarn dev
and second one is only used in end-to-end tests. Corresponding TypeORM configs are defined in ormconfig.ts
and ormconfig.test.ts
.
If you are just starting to work with the projects it's best to simply run:
yarn && yarn db:reseed
that will create bloom
DB for you, migrate it to the latest schema and seed with appropriate dev data. If running the reseed command requires that you input a password for Postgres, set the following environment variables: PGUSER
to postgres and PGPASSWORD
to the default password you inputted for the postgres user during Postgres installation.
Dropping the DB:
yarn db:drop
Creating the DB:
yarn db:create
Seeding the DB:
yarn db:seed
Generating a new migration:
yarn db:migration:generate
Applying migrations:
yarn db:migration:run
Installing Redis
You can install Redis using Homebrew with the following command: brew install redis
.
To start Redis:
redis-server
.
To have launch Redis as background service and restart at login:
brew services start redis
.
Test if Redis is working:
redis-cli ping
Running Tests
End-to-end tests:
yarn test:e2e:local
Unit tests:
yarn test