provapraticabackend/README.md
AV77web 895860e906
All checks were successful
Deploy to VPS / build (push) Successful in 18s
Deploy to VPS / deploy (push) Successful in 20s
correzioni finali
2026-06-09 15:44:48 +02:00

68 lines
1.9 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Backend Gestione Rimborsi Spese Aziendali (Prova S5)
API REST per la gestione delle richieste di rimborso spese aziendali.
## URL produzione
| Risorsa | URL |
|---------|-----|
| API | https://provapraticabackend.andreavillari.it |
| Health check | https://provapraticabackend.andreavillari.it/api/health |
| Swagger UI | https://provapraticabackend.andreavillari.it/api/docs |
| Frontend collegato | https://provapraticafrontend.andreavillari.it |
## Credenziali di test
Password comune per tutti gli utenti: `Password123!`
| Ruolo | Email |
|-------|-------|
| Responsabile amministrativo | `admin@azienda.it` |
| Dipendente | `mario.rossi@azienda.it` |
| Dipendente | `marco.bianchi@azienda.it` |
| Dipendente | `anna.verdi@azienda.it` |
È possibile anche registrare nuovi utenti da `/register` sul frontend, scegliendo il ruolo.
## Avvio locale
Configurare il file `.env` (AUTH_SECRET, credenziali DB, URL frontend/backend, ecc.).
```bash
npm install
npm run dev
```
Con Docker (app + MySQL + phpMyAdmin):
```bash
docker compose up -d --build
```
MySQL è esposto su `127.0.0.1:3307`, l'app su `127.0.0.1:3003`.
Gli script in `initdb/` vengono eseguiti **solo al primo avvio** del volume MySQL (database vuoto).
## Dati iniziali
Il seed (`initdb/02_seed.sql`) crea:
- 4 utenti di test (1 responsabile, 3 dipendenti)
- 5 categorie di spesa
- 10 richieste di rimborso in tutti gli stati (`IN_ATTESA`, `APPROVATA`, `RIFIUTATA`, `LIQUIDATA`)
Se il database di produzione è stato creato **prima** dell'aggiornamento del seed:
- ricreare il volume Docker (`docker compose down -v` poi `up`), oppure
- eseguire `scripts/apply-missing-test-users.sql` via phpMyAdmin o CLI MySQL
## Stack
- Node.js 20, Express, TypeScript
- MySQL 8
- Auth.js (sessione JWT via cookie)
- Swagger UI (`/api/docs`)
## Deploy
Push su `main` → Forgejo Actions → SSH sul VPS → `docker compose up -d --build` in `/root/provapraticabackend`.