refactor: restructure frontend and backend by domain services
PR — Ouverture automatique / create-pr (push) Successful in 3s
PR — Ouverture automatique / create-pr (push) Successful in 3s
Split the monolithic backend (lib/, routes/, access.ts, storage.ts, media.ts) into a layered structure inspired by JeanXXIII-CRM: - config/: appConfig, db - middleware/: auth (session, roles, cookies) - models/: shared types - routes/: *Routes.ts (thin HTTP handlers) - services/: *Service.ts (business logic, one per domain) - utils/: errors, http, migrate, ratelimit, validators, service bootstrap Frontend likewise: services/*Service.ts + apiClient, contexts/, types/, utils/format. Route files now carry the "Routes" suffix; service files are named authService.ts, ratelimit.ts, etc. and live in their own files, frontend and backend separated. Updated docs and READMEs to reflect the new layout. Typecheck and builds pass.
This commit is contained in:
+8
-8
@@ -33,13 +33,13 @@ fichier est copié dans l'image, pas monté.
|
||||
|
||||
## Modifier une route
|
||||
|
||||
1. Schéma d'entrée : Zod dans `backend/src/routes/<entity>.ts`.
|
||||
2. Droits : passer par `backend/src/access.ts` (jamais par un paramètre
|
||||
venu du client).
|
||||
1. Schéma d'entrée : Zod dans `backend/src/routes/<entity>Routes.ts`.
|
||||
2. Droits : passer par `backend/src/services/auditService.ts` (jamais par un
|
||||
paramètre venu du client).
|
||||
3. Réponse : renvoyer **404** si la ressource n'est pas censée exister pour ce
|
||||
compte, 403 seulement pour une règle explicite.
|
||||
4. Erreur métier : `AppError` depuis `backend/src/lib/errors.ts`.
|
||||
5. Audit si l'action est sensible (`audit()` dans `access.ts`).
|
||||
4. Erreur métier : `AppError` depuis `backend/src/utils/errors.ts`.
|
||||
5. Audit si l'action est sensible (`audit()` dans `services/auditService.ts`).
|
||||
6. `make check`, puis redémarrage de l'API (`docker compose up -d api`).
|
||||
|
||||
## Modifier le schéma
|
||||
@@ -65,10 +65,10 @@ Le design system vit dans `frontend/src/ui` (+ `src/styles`).
|
||||
|
||||
| Besoin | Fichier |
|
||||
| --- | --- |
|
||||
| Droit d'accès à un dossier/fichier | `backend/src/access.ts` |
|
||||
| Droit d'accès à un dossier/fichier | `backend/src/services/auditService.ts` |
|
||||
| Taille/quota par défaut | migration `004`, table `users` / `settings` |
|
||||
| Chemin physique des fichiers | `backend/src/storage.ts` |
|
||||
| En-têtes, CORS, healthz | `backend/src/lib/http.ts` |
|
||||
| Chemin physique des fichiers | `backend/src/services/storageService.ts` |
|
||||
| En-têtes, CORS, healthz | `backend/src/utils/http.ts` |
|
||||
| Durée de session | `SESSION_TTL_HOURS` |
|
||||
| Port | `COHAISE_HTTP_PORT` (nginx), `COHAISE_API_PORT` (API) |
|
||||
| Interface (parcours dossiers) | `frontend/src/pages/Browser.tsx` |
|
||||
|
||||
Reference in New Issue
Block a user