Skip to content

roastery-cms/capsules.models_models-type

Repository files navigation

@roastery-capsules/models.models-type

Models type management capsule for the Roastery CMS ecosystem.

Checked with Biome

Overview

@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

Technologies

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

Installation

bun add @roastery-capsules/models.models-type

Peer dependencies (install alongside):

bun add @types/bun tsup typescript

Usage

import { Elysia } from 'elysia';
import { ModelsTypeRoutes } from '@roastery-capsules/models.models-type/presentation';

const app = new Elysia()
  .use(ModelsTypeRoutes({ repository }))
  .listen(3000);

Models type entity

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

Creating a models type

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>"
}

Listing models types

GET /models-types/?page=1

Getting a models type by ID or slug

GET /models-types/review
GET /models-types/<uuid>

Updating a models type

PATCH /models-types/review?update-slug=true
Content-Type: application/json
Authorization: Bearer <token>

{
  "name": "Book Review",
  "description": "A review about a book."
}

Deleting a models type

DELETE /models-types/review
Authorization: Bearer <token>

Development

# 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 setup

License

MIT

About

Models type management capsule for the Roastery CMS ecosystem — CRUD operations with schema definition, slug generation, pagination, and optional caching.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors