54 lines
1.5 KiB
Markdown
54 lines
1.5 KiB
Markdown
# YuGiOh Collection Manager — API
|
|
|
|
Node.js/Express API for the YuGiOh collection manager. Handles card data, set browsing, image serving, and DB imports from YGOPRODeck.
|
|
|
|
## Tech Stack
|
|
|
|
- **Node.js** + **Express 5**
|
|
- **MySQL2** (connection pool)
|
|
- **Axios** — YGOPRODeck API requests + card image fetching
|
|
|
|
## Endpoints
|
|
|
|
| Method | Path | Description |
|
|
|---|---|---|
|
|
| GET | `/health` | Health check |
|
|
| GET | `/exportCards` | All cards with printings and owned counts |
|
|
| GET | `/cardImage/:cardId` | Card image (fetches + caches blob on first request) |
|
|
| GET | `/sets` | All sets with owned card counts |
|
|
| GET | `/sets/:setId/cards` | Cards in a specific set |
|
|
| PUT | `/collection/amount` | Update owned count for a printing |
|
|
| POST | `/import/full-import` | Full DB import from YGOPRODeck |
|
|
| POST | `/import/sets` | Import sets only |
|
|
| POST | `/import/cards` | Import cards only |
|
|
| GET | `/db-version` | Current local DB version |
|
|
|
|
## Development
|
|
|
|
```bash
|
|
npm install
|
|
cp .env.example .env # fill in DB credentials
|
|
node src/index.js
|
|
```
|
|
|
|
## Deployment
|
|
|
|
Built as a Docker image. CI/CD via Woodpecker on push to `main`.
|
|
|
|
```bash
|
|
docker build -t yugioh-api .
|
|
docker run -d --name yugioh-api --network yugioh --env-file .env yugioh-api
|
|
```
|
|
|
|
## Environment
|
|
|
|
| Variable | Description |
|
|
|---|---|
|
|
| `DB_HOST` | MySQL host |
|
|
| `DB_PORT` | MySQL port (default 3306) |
|
|
| `DB_USER` | MySQL user |
|
|
| `DB_PASSWORD` | MySQL password |
|
|
| `DB_NAME` | Database name |
|
|
| `YGOPRO_API_BASE` | YGOPRODeck API base URL |
|
|
| `PORT` | Server port (default 3000) |
|