Models type management capsule for the Roastery CMS ecosystem.
@roastery-capsules/models.models-type is an Elysia capsule that provides full CRUD management for models types, including TypeBox schema definition, automatic slug generation, uniqueness validation, pagination, and optional Redis caching.
It exposes ModelsTypeRoutes, an Elysia plugin ready to be mounted in your application, with the following endpoints:
| Method | Path | Auth | Description |
|---|---|---|---|
POST |
/models-types/ |
Required | Create a new models type |
GET |
/models-types/ |
Public | List models types (paginated) |
GET |
/models-types/:id-or-slug |
Public | Get models type by ID or slug |
PATCH |
/models-types/:id-or-slug |
Required | Update a models type |
DELETE |
/models-types/:id-or-slug |
Required | Delete a models type |
| Tool | Purpose |
|---|---|
| Elysia | HTTP framework and plugin target |
| @roastery/barista | Elysia application factory |
| @roastery/terroir | Runtime schema validation and exception handling |
| @roastery/beans | Domain entity base class |
| @roastery/seedbed | Repository and use-case contracts |
| @roastery-adapters/models | Prisma models repository adapter |
| @roastery-adapters/cache | Redis caching adapter |
| @roastery-capsules/auth | Authentication plugin |
| Prisma | ORM for data persistence |
| tsup | Bundling to ESM + CJS with .d.ts generation |
| Bun | Runtime, test runner, and package manager |
| Knip | Unused exports and dependency detection |
| Husky + commitlint | Git hooks and conventional commit enforcement |
bun add @roastery-capsules/models.models-typePeer dependencies (install alongside):
bun add @types/bun tsup typescriptimport { Elysia } from 'elysia';
import { ModelsTypeRoutes } from '@roastery-capsules/models.models-type/presentation';
const app = new Elysia()
.use(ModelsTypeRoutes({ repository }))
.listen(3000);Each ModelsType has the following properties:
| Field | Type | Description |
|---|---|---|
name |
string |
Display name (e.g. "Review", "Product") |
slug |
string |
URL-friendly identifier (auto-generated from name) |
description |
string |
Brief description of the models type |
schema |
string |
Serialized TypeBox schema defining the content structure |
POST /models-types/
Content-Type: application/json
Authorization: Bearer <token>
{
"name": "Review",
"description": "A review written by a user about a product.",
"schema": "<serialized TypeBox schema via SchemaManager>"
}GET /models-types/?page=1GET /models-types/review
GET /models-types/<uuid>PATCH /models-types/review?update-slug=true
Content-Type: application/json
Authorization: Bearer <token>
{
"name": "Book Review",
"description": "A review about a book."
}DELETE /models-types/review
Authorization: Bearer <token># Run tests
bun run test:unit
# Run tests with coverage
bun run test:coverage
# Build for distribution
bun run build
# Check for unused exports and dependencies
bun run knip
# Full setup (build + bun link)
bun run setupMIT