@terreno/admin-backend
v57.6.1
Published
Admin panel backend plugin for @terreno/api — part of Terreno, the batteries-included TypeScript framework for universal apps.
Downloads
1,732
Readme
@terreno/admin-backend
Admin panel backend plugin for @terreno/api.
See Add a model to the admin for the recommended
modelRouter({admin: ...}) setup.
Admin panel backend plugin for @terreno/api that auto-generates admin CRUD endpoints and metadata for Mongoose models.
Install
bun add @terreno/admin-backend @terreno/api mongooseQuick start
import {TerrenoApp} from "@terreno/api";
import {AdminApp} from "@terreno/admin-backend";
import {User, Todo} from "./models";
new TerrenoApp({userModel: User})
.register(
new AdminApp({
basePath: "/admin",
models: [
{
model: User,
routePath: "/users",
displayName: "Users",
listFields: ["email", "name", "admin"],
defaultSort: "-created",
},
{
model: Todo,
routePath: "/todos",
displayName: "Todos",
listFields: ["title", "completed", "ownerId"],
},
],
})
)
.start();This creates GET /admin/config plus full CRUD at /admin/users and /admin/todos, all protected with Permissions.IsAdmin.
What's included
AdminApp— registers admin routes and the config metadata endpointDocumentStorageApp— optional GCS document browser routes for adminsrunScriptCli— CLI helper for admin script execution- Auto-generated CRUD via
modelRouterwithIsAdminon every route GET /admin/config— field metadata extracted from Mongoose schemas and OpenAPI- Admin UI v2 route helpers (
adminUiV2exports) - TypeScript types:
AdminModelConfig,AdminOptions,AdminFieldOverride, and more
Documentation
Full API reference: docs/reference/admin-backend.md
License and Contributing
Licensed under the MIT License. See CONTRIBUTING.md for contribution guidelines.
