DE
Beta-Übersetzung

@core / admin

1.0.1 ▾
verifiziertMIT
GitHub

Admin-Panel aus AdminResource generiert: Listen, Formulare, Aktionen, Dashboard, RBAC, CSRF-Schutz und Audit-Log

Code12 DateienKontext~849 TokensPrüfung bestanden

Installieren

$genpm add @core/admin

Was du bekommst

  • Quellcode in src/lib/admin/, 12 Dateien. (56,9 kB)
  • KI-Regeln in src/lib/admin/AGENTS.md, dazu Regeldateien für die IDE.
  • Löst @core/auth, @core/contracts, @core/db, @core/rbac, @core/ui für dich auf.

README

@core/admin

genpm license

Admin panel generated from AdminResource: lists, forms, actions, dashboard, RBAC, CSRF protection and audit log

A GenPM module: source code + AI rules + MCP config, injected into your project instead of hidden in node_modules. The code lands in src/lib/admin, pinned to a verified commit, and you own it.

Install

genpm add @core/admin

No genpm yet? curl -fsSL https://genpm.net/install.sh | sh (macOS/Linux), irm https://genpm.net/install.ps1 | iex (Windows), or one-off with npx @genpm-net/cli add @core/admin.

Or let your AI agent do it: run genpm mcp setup once, then ask "add @core/admin with genpm" in Claude Code, Cursor, VS Code, Windsurf, Codex or Gemini CLI. It shows you a dry-run plan before writing anything.

What it does

Admin panel generated from AdminResource descriptions (from @core/contracts): navigation, dashboard widgets, searchable/sortable lists, create/edit forms, record actions with confirmation, and delete. No per-resource screens: any module that exports an AdminResource appears in the panel. Server side: session from @core/auth, permissions from @core/rbac (admin:access + <resource>:<action>), CSRF protection on writes and an audit log of every change. Table: admin_audit.

Setup

After genpm add, follow these steps (your AI agent finds the same steps in src/lib/admin/AGENTS.md and can do them for you):

  1. Install @core/auth, @core/rbac and @core/ui first; run migrations as in src/lib/db/AGENTS.md (admin_audit).
  2. Create src/genpm/admin.ts:
    import { defineAdmin, auditAdminResource } from '@/lib/admin';
    import { mediaAdminResource } from '@/lib/media';
    export const admin = defineAdmin({ title: 'My site', resources: [mediaAdminResource, auditAdminResource], widgets: [] });
    Every installed module's AGENTS.md says which resources to add here.
  3. API route. Next: app/api/admin/[...path]/route.ts → export const { GET, POST, PUT, DELETE } = adminRouteHandlers(admin); export const dynamic = 'force-dynamic'; Hono: app.route('/api/admin', adminRoutes(admin)).
  4. Page. Next: app/admin/[[...path]]/page.tsx renders a client component that imports ../lib/ui/ui.css, ../lib/admin/admin.css and returns <AdminApp basePath="/admin" path={(await params).path?.join('/') ?? ''} />. Protect the page itself too (redirect to sign-in when there is no session) and add robots: { index: false }.
  5. Rich text, media pickers or blocks: pass renderers={{ richText: MyEditorField, media: MyMediaPicker }}. Without them those fields fall back to a JSON textarea / relation select.
  6. Translate the UI with labels={{ save: t('admin.save'), … }} (keys: defaultLabels).
  7. Verify: a user without admin:access gets 403 on /api/admin/schema; an editor sees only their resources; an edit creates a row in admin_audit with before/after.

What's inside

Paths are relative to src/lib/admin.

  • index.ts — server API: defineAdmin, handleAdminApi, adminContextFor, listAudit, auditAdminResource, countWidget, listWidget, fieldsFromZod.
  • client.ts — 'use client': AdminApp, createAdminApi, FieldControl, defaultLabels, renderer types.
  • admin.css — layout on @core/ui tokens. constants.ts — ADMIN_HEADER (shared by server and client).
  • adapters/hono.ts — adminRoutes(admin). adapters/next.ts — adminRouteHandlers(admin).

At a glance

Security

GenPM installs a 40-character commit SHA (never a branch), verifies an Ed25519-signed manifest, never runs install scripts and scans AI rules for prompt injection. Details: genpm.net/docs/security.

License

MIT — see LICENSE. Browse the full catalog at genpm.net.

@core/admin melden

Melde dich mit GitHub an, um ein Paket zu melden.