Development
Start Services
To start all services (API, Console) simultaneously, use the task command from the root directory:Run Workers
To run workers locally, use the task command from the root directory:Generate Function Call API
To run generate function call api, use the task command from the root directory:Database
Setup
Thetask init command automatically starts a PostgreSQL container using Docker. The database connection details are configured in core-api/.env.
If you prefer to use your own PostgreSQL instance, update the core-api/.env file accordingly.
Migration
Overview
Database migrations are managed using TypeORM. The migration scripts are defined incore-api/taskfile.yml and can be executed using the task commands.
Run Migrations
Run All Pending Migrations
This command executes all pending database migrations:- Connect to the PostgreSQL database
- Check for pending migrations in the
migrationstable - Run all new migrations that haven’t been applied yet
Generate Migration
To generate a new migration with a custom name:core-api/src/database/migrations/.
Revert Last Migration
To rollback the most recently executed migration:Migration with Docker
Using Docker Compose
If you prefer to run migrations using Docker (useful when not running PostgreSQL locally):- Start the PostgreSQL container (if not running)
- Run the migration service
- Execute all pending migrations
- Automatically remove the migration container after completion
- Start the core-api service after migrations complete
Manual Run
To run migration container manually and keep it for debugging:--rm flag ensures the container is removed after it stops.
Development Conventions
Code Style
- Core API (NestJS): Uses ESLint and Prettier for code formatting and linting. Currently, you need to run
npm run lintandnpm run formatdirectly from thecore-apidirectory. Consider creating a task to wrap these commands for convenience. - Console (React): Uses ESLint and Prettier. Currently, you need to run
npm run lintdirectly from theconsoledirectory. Consider creating a task to wrap this command for convenience. - Workers (Bun): Likely follows standard TypeScript conventions. You may need to run linting/formatting commands directly from the
workerdirectory.
Testing
-
Core API: Uses Jest for testing. Currently, you need to run the following commands directly from the
core-apidirectory:- Run unit tests:
npm run test - Run tests in watch mode:
npm run test:watch - Run end-to-end tests:
npm run test:e2eConsider creating tasks to wrap these commands for convenience.
- Run unit tests:
Docker
Using Docker Compose
To run the entire stack, including the database, using Docker Compose:docker-compose.yml to orchestrate containers.