Be.tech backend APIs for mobile and web clients. It uses Node.js with TypeScript with DDD as architectural approach.
- Our main web framework is
Nestjsand various dependencies from the Nestjs ecosystem. - To store data we use the
PostgreSQLdatabase and Prisma as ORM. - For the API documentation, we use code first flow with the
Swagger2.0 plugin. Swagger specification is our single source of truth for the documentation.
| Tool | Version |
|---|---|
| node | 16.15.1 |
| pnpm | 7.1.9 |
| npm | 8.5.5 |
| Docker | 20.10 |
| Docker Compose | 2.6.0 |
- Copy example environment variables:
cp .env.example .env - Edit
.envfile and update configuration
- Install Node.js: https://nodejs.org/en/download/
- Install Docker: https://docs.docker.com/get-docker/
pnpm install
To run all dependencies for local development, please use Docker and Docker Compose:
- Copy example Docker Compose configuration:
cp docker-compose.yml.example docker-compose.yml - Make sure you already copied the
.envfile as described in the setup section - Startup database container by command:
docker compose up <serviceName1> <serviceNameN>or usepnpm docker:upcommand to start all dependent service containers.
pnpm docker:up - starts all docker services by Docker Compose except application service.
pnpm docker:down - stops all docker services.
- Copy example Docker Compose configuration:
cp docker-compose.yml.example docker-compose.yml - Make sure you already copied the
.envfile as described in the setup section - Build containers by command:
docker compose build - Startup containers by command:
docker compose up
- Make sure you already copied the
.envfile as described in the setup section - Make sure you already have the database up and running and configured connection by the
.envfile (to set up a local database and other dependencies you can use Docker, please see "Run local database and other dependencies by Docker" section) - Run
pnpm db:migrateto create database schema (tables, indexes, etc)
pnpm start:dev - starts the application, watches the code and automatically recompiles typescript code, and restarts the application
pnpm lint - lints the code using both eslint and prettier
To update database schema, please use following pnpm scripts: db:*
pnpm db:generate
All generated code will be stored here: ./node_modules/.prisma (default)
pnpm db:validate
pnpm db:migrate
pnpm db:reset
pnpm db:deploy
For more details, please take a look on Prisma documentation: https://www.prisma.io/docs/
These environment variables are required to start the container in the natural environment (i.e. AWS).
| Name | Description |
|---|---|
| WEB_PORT | Http application port |
| DATABASE_URL | Database connection url in format: postgresql://host/db |
| REDIS_HOST | IP or url for connection to Redis |
| REDIS_PORT | TCP port for connection to Redis |
| REDIS_PASS | Password for connection to Redis. If redis has a password |
| REDIS_DB | Redis batabase index |