Initial commit

**Motivations:**
- Initialisation du versionning git pour le projet

**Root causes:**
- N/A (Nouveau projet)

**Correctifs:**
- N/A

**Evolutions:**
- Structure initiale du projet
- Ajout du .gitignore

**Pages affectées:**
- Tous les fichiers
This commit is contained in:
2026-03-03 22:24:17 +01:00
commit e031c9a1d2
155 changed files with 22334 additions and 0 deletions

40
server/README.md Normal file
View File

@@ -0,0 +1,40 @@
# Build a Zoo — API server
Node + Express + PostgreSQL. Auth by Ed25519 keypair (pseudo, no password). Zoos and game state persisted in DB; bots ensure minimum zoo density on the map.
## Prerequisites
- Node 18+
- PostgreSQL (create a database, e.g. `builazoo`)
## Setup
```bash
npm install
createdb builazoo # or your DB name
psql -d builazoo -f schema.sql
```
Set environment:
- `DATABASE_URL`: connection string (default `postgres://localhost/builazoo`)
- `PORT`: HTTP port (default `3000`)
## Run
```bash
npm start
```
API base URL is `http://localhost:3000` (or your host/port). From the web client, set `window.BUILAZOO_API_URL` to this URL before loading the app (e.g. in HTML or via build env) to enable sign-up and sync. For local testing you can also open the web app with `?api=http://localhost:3000` (or your API origin).
## Endpoints
- `GET /api/health` — health check
- `POST /api/auth/register` — create account (body: `{ pseudo }`, header: `X-Public-Key` base64url)
- `GET /api/zoos` — list zoos for map (creates bots if below `minZoos`)
- `GET /api/zoos/me` — get my zoo + game_state (signed)
- `POST /api/zoos/me` — create my zoo (signed, body: `{ name?, game_state }`)
- `PATCH /api/zoos/me` — update game_state (signed, body: `{ game_state }`)
Signed requests use headers: `X-Public-Key`, `X-Signature`, `X-Timestamp`. Message signed = `method + path + timestamp + SHA256(body)`.