Skip to content

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 :

json
{
  "name": "John Doe",
  "email": "john@exemple.com",
  "password": "motdepasse123"
}

Reponse : 200 — informations de session

POST /api/auth/sign-in/email

Se connecter.

Body :

json
{
  "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

json
[
  {
    "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 :

json
{
  "domain": "app.exemple.com",
  "config": "  reverse_proxy http://backend:8080\n  log { ... }",
  "upstream": "http://backend:8080"
}
CodeDescription
201Vhost cree, Caddy recharge
400domain ou config manquant
409Domaine deja existant
502Caddy a refuse la configuration (rollback effectue)

PUT /api/vhosts/:id

Modifier un vhost existant. Tous les champs sont optionnels.

Body :

json
{
  "domain": "app.exemple.com",
  "config": "  reverse_proxy http://new-backend:8080\n  ...",
  "upstream": "http://new-backend:8080"
}
CodeDescription
200Vhost modifie, Caddy recharge
404Vhost introuvable
502Caddy a refuse la configuration (rollback effectue)

DELETE /api/vhosts/:id

Supprimer un vhost.

CodeDescription
200{ "success": true }
404Vhost introuvable
502Caddy a refuse la configuration (rollback effectue)

PATCH /api/vhosts/:id/toggle

Activer ou desactiver un vhost (inverse l'etat actuel).

CodeDescription
200Vhost mis a jour
404Vhost introuvable
502Caddy a refuse la configuration (rollback effectue)

Logs

GET /api/logs

Recuperer les logs d'acces Caddy.

Query params :

ParamTypeDefaultDescription
domainstringFiltrer par domaine
statusintegerFiltrer par code HTTP
pageinteger1Numero de page

Reponse : 200

json
{
  "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

json
[
  {
    "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

json
{ "status": "ok" }