Backend for frontend is a series of backend services and libraries that enhance user experience for the frontend.
Install dependencies:
yarn
Create the .env
file:
# If you are not using docker
cp .env.example .env
# If you are using docker (handy to launch a service directly using NX)
cp .env.example .env.docker
Start docker:
yarn compose:up
Make sure your .env
file is defined, if not create one using .env.example
as a template.
# Start RabbitMQ
docker-compose up -d queue
# Start the notification producer
yarn producer
To add a new app or library, you can run the following command;
# New API
yarn new:fastify
# New Library
yarn new:lib
# New Node app
yarn new:node
For APIs and apps, it will create a Dockerfile. Please, remember to update:
- The
docker-compose.yml
file to include the new service. - The github actions to include the new service (
.github/workflows/ci.yml
)
For more info, see:
- @nx/node:application: Generator for Applications
- @nx/node:application (Fastify): Generator for API Applications using Fastify
- @nx/node:setup-docker: Generator for NodeJS Libraries
- @nx/node:setup-docker: Docker Generator
# Run all tests
yarn test
# Run test for repositories (in watch mode)
nx run repositories:test --watch
# Run test on specific file (in watch mode)
nx run repositories:test --watch --testFile=libs/repositories/src/UsdRepository/UsdRepositoryRedis.spec.ts
Build docker containers and publish to a local registry:
yarn docker-build:affected
There's some API types that are generated automatically from their swagger definitions. To generate them, run:
yarn gen:types
{"type":"DriverPackageNotInstalledError","message":"Postgres package has not been found installed. Try to install it: npm install pg --save","stack":"DriverPackageNotInstalledError: Postgres package has not been found installed. Try to install it: npm install pg
If you have faced the error above - check this fix and its description: #101