Main backend API service for the CORE game website.
This NestJS service serves as the primary backend, handling:
- User authentication and management
- Team and event/tournament management
- Match results and statistics
- Database operations (PostgreSQL)
- RabbitMQ microservice communication
Install pnpm:
corepack enable && corepack prepare pnpm@latest --activateor
brew install pnpm-
Install dependencies:
pnpm install
-
Set up environment variables:
cp .env.example .env
Edit
.env.localwith your configuration (see Environment Variables below). -
Run database migrations:
pnpm migration:run-local
-
Run development server:
pnpm start:dev
- Build:
pnpm build - Start:
pnpm start:prod
DB_HOST- PostgreSQL hostDB_PORT- PostgreSQL portDB_USER- Database usernameDB_PASSWORD- Database passwordDB_NAME- Database nameDB_SCHEMA- Database schemaDB_URL- Alternative database connection URL overwrites the other database connection variablesDB_SSL_REQUIRED- Enable SSL connection (true/false)
RABBITMQ_URL- RabbitMQ connection URLAPI_SECRET_ENCRYPTION_KEY- Key for encrypting sensitive data
PORT- Server port (default: 4000)NODE_ENV- Environment (development/production)
- Generate:
pnpm migration:generate migration_nameCompares your current TypeScript entities with the database and automatically generates the necessary SQL (e.g., adding or removing columns). Use this for most schema changes. - Create:
pnpm migration:create migration_nameCreates an empty migration template. Use this only for manual SQL changes (e.g., seeding data, creating complex views, or custom indexes) that TypeORM cannot detect automatically. - Run:
pnpm migration:run-local(local) /pnpm migration:run(production) - Revert:
pnpm migration:revert-local(local) /pnpm migration:revert(production)
- Seed Users and Teams:
pnpm seed:users <eventId>Generates 90 users and 30 teams (3 members each) and assigns them to the specified event. This is useful for testing group phases and bracket logic.
When running in development mode, Swagger documentation is available at:
http://localhost:4000/api
This service runs as both:
- REST API - HTTP endpoints for frontend communication
- Microservice - RabbitMQ message consumer for:
game_results- Match result processinggithub-service-results- GitHub operation results
- Go to GitHub → Settings → Developer settings → OAuth Apps
- Register a new OAuth app
- Set Authorization callback URL:
http://localhost:4000/auth/github/callback - Add Client ID and Secret to
.env.local
For testing account linking functionality:
- Go to 42 School → Settings → API → Applications
- Create a new application
- Set Redirect URI:
http://localhost:4000/auth/42/callback - Add Client ID and Client Secret to
.env.local