refactor(admin): split protect guards into dedicated export path
- remove `protectAdmin`/`isAdmin` re-exports from `features/admin/index.js` to avoid top-level `next/headers` import - add `./features/admin/protect` export entry in `package.json` - lazy-import `next/headers` in `router.js` `requireAuth` to defer resolution - update `features/admin/README.md` to document new import paths - translate `features/auth/index.js` comment to French for consistency
This commit is contained in:
@@ -10,7 +10,7 @@ Ce répertoire fournit l'interface d'administration complète : layout, navigati
|
||||
|
||||
```
|
||||
src/features/admin/
|
||||
├── index.js protectAdmin, isAdmin, buildNavigationSections, registre
|
||||
├── index.js buildNavigationSections, registre (Next.js-free)
|
||||
├── protect.js gardes d'accès
|
||||
├── navigation.js buildNavigationSections, buildBottomNavItems
|
||||
├── registry.js registre runtime d'extensions
|
||||
@@ -50,7 +50,11 @@ src/features/admin/
|
||||
## Import
|
||||
|
||||
```js
|
||||
import { protectAdmin, isAdmin, buildNavigationSections } from '@zen/core/features/admin';
|
||||
// Gardes RSC — chemin dédié (next/navigation + next/headers, non compatible turbopackIgnore)
|
||||
import { protectAdmin, isAdmin } from '@zen/core/features/admin/protect';
|
||||
|
||||
// Registre et navigation — compatible modules externes
|
||||
import { buildNavigationSections } from '@zen/core/features/admin';
|
||||
import {
|
||||
registerWidget,
|
||||
registerWidgetFetcher,
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
/**
|
||||
* Zen Admin — barrel serveur.
|
||||
* Zen Admin — barrel serveur (Next.js-free).
|
||||
*
|
||||
* - Gardes d'accès : protectAdmin, isAdmin.
|
||||
* - Navigation : buildNavigationSections.
|
||||
* - Registre d'extensions : registerWidget, registerWidgetFetcher, registerNavItem,
|
||||
* registerNavSection, registerPage (import une seule fois depuis le layout
|
||||
* racine de l'app consommatrice pour que les side effects s'exécutent).
|
||||
*
|
||||
* Ne re-exporte PAS protect.js — ce fichier importe `next/navigation` et
|
||||
* `@zen/core/features/auth/actions` (qui importe `next/headers`) au niveau
|
||||
* top-level. Ce barrel est importé par des modules externes pendant leur
|
||||
* register(), avant que Next.js ait activé ses alias de modules.
|
||||
* Importer les gardes explicitement via @zen/core/features/admin/protect.
|
||||
*
|
||||
* Client components sous @zen/core/features/admin/components.
|
||||
*/
|
||||
|
||||
export { protectAdmin, isAdmin } from './protect.js';
|
||||
export { buildNavigationSections } from './navigation.js';
|
||||
export {
|
||||
registerWidget,
|
||||
|
||||
Reference in New Issue
Block a user