Hub API
Toutes les routes (sauf /api/health et /api/auth/*) necessitent une session authentifiee via cookie.
Base URL : /api
Authentification
L'authentification est geree par Better Auth. Toutes les routes auth sont prefixees par /api/auth.
POST /api/auth/sign-up/email
Creer un nouveau compte.
Body :
{
"name": "John Doe",
"email": "john@exemple.com",
"password": "motdepasse123"
}Reponse : 200 — informations de session
POST /api/auth/sign-in/email
Se connecter.
Body :
{
"email": "john@exemple.com",
"password": "motdepasse123"
}Reponse : 200 — cookie de session
POST /api/auth/sign-out
Se deconnecter. Invalide la session en cours.
Vhosts
GET /api/vhosts
Liste tous les vhosts, tries par domaine.
Reponse : 200
[
{
"id": 1,
"domain": "app.exemple.com",
"config": " reverse_proxy http://backend:8080\n ...",
"enabled": true,
"upstream": "http://backend:8080",
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z"
}
]POST /api/vhosts
Creer un nouveau vhost.
Body :
{
"domain": "app.exemple.com",
"config": " reverse_proxy http://backend:8080\n log { ... }",
"upstream": "http://backend:8080"
}| Code | Description |
|---|---|
201 | Vhost cree, Caddy recharge |
400 | domain ou config manquant |
409 | Domaine deja existant |
502 | Caddy a refuse la configuration (rollback effectue) |
PUT /api/vhosts/:id
Modifier un vhost existant. Tous les champs sont optionnels.
Body :
{
"domain": "app.exemple.com",
"config": " reverse_proxy http://new-backend:8080\n ...",
"upstream": "http://new-backend:8080"
}| Code | Description |
|---|---|
200 | Vhost modifie, Caddy recharge |
404 | Vhost introuvable |
502 | Caddy a refuse la configuration (rollback effectue) |
DELETE /api/vhosts/:id
Supprimer un vhost.
| Code | Description |
|---|---|
200 | { "success": true } |
404 | Vhost introuvable |
502 | Caddy a refuse la configuration (rollback effectue) |
PATCH /api/vhosts/:id/toggle
Activer ou desactiver un vhost (inverse l'etat actuel).
| Code | Description |
|---|---|
200 | Vhost mis a jour |
404 | Vhost introuvable |
502 | Caddy a refuse la configuration (rollback effectue) |
Logs
GET /api/logs
Recuperer les logs d'acces Caddy.
Query params :
| Param | Type | Default | Description |
|---|---|---|---|
domain | string | — | Filtrer par domaine |
status | integer | — | Filtrer par code HTTP |
page | integer | 1 | Numero de page |
Reponse : 200
{
"logs": [
{
"timestamp": "2025-01-15T10:30:00.000Z",
"domain": "app.exemple.com",
"method": "GET",
"path": "/api/data",
"status": 200,
"latency": "12.3ms",
"ip": "192.168.1.1"
}
],
"total": 150,
"page": 1,
"pageSize": 50
}Changelog
GET /api/changelog
Recuperer les 100 dernieres entrees du changelog.
Reponse : 200
[
{
"id": 1,
"userId": "abc123",
"userName": "John Doe",
"action": "create",
"domain": "app.exemple.com",
"diff": null,
"createdAt": "2025-01-15T10:30:00.000Z"
}
]Les valeurs possibles pour action : create, update, delete, toggle.
Pour les actions update, le champ diff contient un JSON stringifie avec les cles old et new.
Health
GET /api/health
Health check. Pas d'authentification requise.
Reponse : 200
{ "status": "ok" }