Skip to main content

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

The task 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 in core-api/taskfile.yml and can be executed using the task commands.

Run Migrations

Run All Pending Migrations
This command executes all pending database migrations:
This will:
  • Connect to the PostgreSQL database
  • Check for pending migrations in the migrations table
  • Run all new migrations that haven’t been applied yet
Generate Migration
To generate a new migration with a custom name:
For example:
This will create a new migration file in core-api/src/database/migrations/.
Revert Last Migration
To rollback the most recently executed migration:
Note: This will only revert one migration at a time. Repeat if needed.

Migration with Docker

Using Docker Compose

If you prefer to run migrations using Docker (useful when not running PostgreSQL locally):
This will:
  1. Start the PostgreSQL container (if not running)
  2. Run the migration service
  3. Execute all pending migrations
  4. Automatically remove the migration container after completion
  5. Start the core-api service after migrations complete

Manual Run

To run migration container manually and keep it for debugging:
The --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 lint and npm run format directly from the core-api directory. Consider creating a task to wrap these commands for convenience.
  • Console (React): Uses ESLint and Prettier. Currently, you need to run npm run lint directly from the console directory. 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 worker directory.

Testing

  • Core API: Uses Jest for testing. Currently, you need to run the following commands directly from the core-api directory:
    • Run unit tests: npm run test
    • Run tests in watch mode: npm run test:watch
    • Run end-to-end tests: npm run test:e2e Consider creating tasks to wrap these commands for convenience.

Docker

Using Docker Compose

To run the entire stack, including the database, using Docker Compose:
This command uses docker-compose.yml to orchestrate containers.