Backend API repository for Greyline.
- Node.js
- TypeScript
- Fastify
- PostgreSQL
- ESLint
- Prettier
- Husky
- lint-staged
- Vitest
This service is responsible for:
- account auth/session basics
- stash and loadout APIs
- NPC selling
- raid result persistence
- future marketplace APIs
Implementation and design specs live in:
BorderRelay/Greyline-Project-Docs
Key docs:
backend-api-implementation-spec.mddatabase-schema-implementation-spec.mdbackend-server-foundation-spec.mdfinal-rdb-structure-with-marketplace.md
npm run devnpm run server:devnpm run server:startnpm run buildnpm run startnpm run checknpm run lintnpm run lint:fixnpm run formatnpm run format:checknpm run testnpm run db:bootstrapnpm run db:migrate
Create a local .env from .env.example before running the server.
Core env keys:
DATABASE_URLDATABASE_SCHEMALOG_LEVELCORS_ORIGINSWAGGER_ENABLEDSWAGGER_ROUTE_PREFIX
The backend connects to a single standalone PostgreSQL Docker container named postgres-sql that is not managed by compose.
The container exposes 5432 on the host and the service uses its own schema inside the shared database.
The container is created and updated with Docker restart policy always so it comes back after daemon or host restarts.
npm run dev first tries the configured DATABASE_URL. If the database is not reachable and the target is local, it starts the managed Docker container and then runs migrations before starting the server.
Commands:
npm run db:bootstrapnpm run db:upnpm run db:statusnpm run db:downnpm run db:migrate
Default schema:
greyline_be
Schema changes are managed through SQL migration files in migrations/.
npm run db:migrate applies unapplied migrations in filename order and records them in greyline_be.schema_migrations.
The backend now uses a plugin-based Fastify baseline with:
- TypeBox route schemas
- shared error envelope
- PostgreSQL startup verification
- Swagger/OpenAPI generation
- development-only Swagger UI by default at
/documentation - auth context stub for future protected routes