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:
40
server/README.md
Normal file
40
server/README.md
Normal 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)`.
|
||||
Reference in New Issue
Block a user