Core Plugins Reference

CatCMS includes several essential core plugins that provide fundamental functionality for your CMS. These plugins are automatically installed and configured when you set up CatCMS. [object Object]

Overview

Core plugins extend CatCMS with critical features like authentication, media management, caching, and database administration. They follow the same plugin architecture as custom plugins, making them excellent examples for plugin development.

Available Core Plugins

πŸ”

Authentication

JWT-based authentication with session management and token refresh

πŸ“§

Email

Transactional email sending via Resend with pre-built templates

πŸ”—

Magic Link Auth

Passwordless authentication using secure email magic links

πŸ“Έ

Media

Media file management with R2 storage and image processing

⚑

Cache

Three-tier caching system with memory, KV, and database layers

πŸ› οΈ

Database Tools

Database administration, migrations, and query tools

🌱

Seed Data

Sample data generation for development and testing


Authentication Plugin

The authentication plugin provides comprehensive user authentication and session management functionality.

Features

  • JWT Token Authentication - Secure token-based authentication
  • Session Management - Track and manage active user sessions
  • Token Refresh - Automatic token renewal without re-authentication
  • Rate Limiting - Protect authentication endpoints from abuse
  • User Context - Inject authenticated user data into request context

Configuration

Plugin Configuration

API Endpoints

POST /api/auth/login Authenticate a user and receive JWT tokens

Login Request

POST /api/auth/logout Invalidate current session

GET /api/auth/me Get current authenticated user information

POST /api/auth/refresh Refresh an expired access token

Services

Auth Service

Hooks

  • auth:login - Triggered when user attempts login
  • auth:logout - Triggered when user logs out
  • request:start - Injects authentication status into requests

Admin Pages

  • /admin/auth/sessions - View and manage active sessions
  • /admin/auth/tokens - Manage API tokens and access keys

Email Plugin

The email plugin provides transactional email functionality using Resend, with pre-built templates for common authentication and notification scenarios.

Features

  • Resend Integration - Send emails via the Resend API
  • Email Templates - Pre-built templates for registration, verification, password reset, and one-time codes
  • Template Customization - Code-based templates that can be customized
  • Logo Support - Add your company logo to email templates
  • Settings Management - Admin UI for configuring email settings
  • Test Email - Send test emails to verify configuration

Configuration

Plugin Configuration

Setup

  1. Sign up for Resend and get your API key
  2. Navigate to /admin/plugins/email/settings in your CatCMS admin
  3. Configure your Resend API key and email settings
  4. Send a test email to verify configuration

Included Email Templates

Registration Confirmation Sent when a new user registers an account

Email Verification Sent to verify user email addresses

Password Reset Sent when users request to reset their password

One-Time Code (2FA) Sent for two-factor authentication codes

API Usage

Sending Emails

Admin Pages

  • /admin/plugins/email/settings - Configure Resend API and email settings

The magic link auth plugin provides passwordless authentication via secure, one-time email links. Users can sign in without remembering passwords.

Features

  • Passwordless Authentication - No passwords required
  • Secure One-Time Links - Links expire after 15 minutes and can only be used once
  • Rate Limiting - Prevent abuse with configurable rate limits
  • Email Integration - Works with the Email plugin for sending magic links
  • Auto User Creation - Optionally create new users when they request a magic link
  • Security Tracking - Logs IP addresses and user agents for security auditing

How It Works

  1. User enters their email address
  2. System generates a secure, random token
  3. Email is sent with a magic link containing the token
  4. User clicks the link to authenticate
  5. Token is validated and marked as used
  6. User is signed in with a JWT session

Configuration

Plugin Configuration

API Endpoints

POST /auth/magic-link/request Request a magic link to be sent via email

Request Magic Link

GET /auth/magic-link/verify?token=… Verify magic link token and sign in the user

Database Schema

Magic Links Table

Security Features

Token Generation Tokens are generated using crypto.randomUUID() twice and concatenated for maximum entropy

Rate Limiting Limits users to 5 magic link requests per hour to prevent abuse

Expiration Links automatically expire after 15 minutes

One-Time Use Each link can only be used once - it’s marked as used immediately after verification

IP Tracking IP addresses and user agents are logged for security auditing

Usage Example

Adding Magic Link to Login Page

Email Template

The magic link email includes:

  • A prominent β€œSign In” button with the magic link
  • Expiration time warning
  • Security notice if the user didn’t request it
  • Modern, responsive design

Media Plugin

The media plugin provides comprehensive media file management with cloud storage integration.

Features

  • File Upload - Upload images, videos, and documents to R2 storage
  • Media Library - Browse and search uploaded media files
  • Image Processing - Resize, compress, and transform images
  • Folder Organization - Organize files into folders
  • Metadata Extraction - Automatic extraction of file metadata
  • Thumbnail Generation - Auto-generate thumbnails for images
  • Bulk Operations - Move, delete, and process multiple files

Configuration

Plugin Configuration

API Endpoints

GET /api/media List media files with pagination and filtering

List Media

POST /api/media/upload Upload a new media file

Upload File

GET /api/media/:id Get media file information and metadata

DELETE /api/media/:id Delete a media file

POST /api/media/process Process media (resize, compress, transform)

POST /api/media/create-folder Create a new folder for organization

POST /api/media/bulk-move Move multiple files to a folder

Services

Media Service

Database Schema

Media Files Table

Hooks

  • media:upload - Triggered when file is uploaded (auto-generates thumbnails)
  • media:delete - Triggered when file is deleted (cleanup related files)
  • content:save - Tracks media references in content

Admin Pages

  • /admin/media - Media library browser
  • /admin/media/upload - File upload interface
  • /admin/media/settings - Media processing configuration

Cache Plugin

The cache plugin implements a sophisticated three-tier caching system for optimal performance.

Features

  • Three-Tier Caching - Memory, Cloudflare KV, and D1 database
  • Automatic Invalidation - Event-based cache invalidation
  • Cache Namespaces - Separate caches for different data types
  • Performance Metrics - Hit rates, latency, and usage statistics
  • Cache Warming - Pre-populate cache with frequently accessed data
  • Pattern Invalidation - Invalidate by wildcard patterns
  • TTL Management - Configurable time-to-live per namespace

Architecture

Request
   ↓
Memory Cache? ──Yes──→ Return (< 1ms)
   ↓ No
KV Cache? ──Yes──→ Populate Memory β†’ Return (10-50ms)
   ↓ No
Database ──→ Populate KV β†’ Populate Memory β†’ Return (100-200ms)

Configuration

Cache Configuration

API Endpoints

GET /admin/cache/stats Get detailed cache statistics for all namespaces

Cache Stats

POST /admin/cache/clear Clear all cache entries across all tiers

POST /admin/cache/invalidate Invalidate cache entries matching a pattern

Invalidate Cache

GET /admin/cache/browser Browse and inspect individual cache entries

POST /admin/cache/warm Pre-populate cache with frequently accessed data

Usage in Code

Using Cache Service

Cache Namespaces

content - Content and pages (TTL: 1 hour) user - User data and profiles (TTL: 15 minutes) api - API response data (TTL: 5 minutes) media - Media file metadata (TTL: 1 hour) auth - Authentication tokens (TTL: 5 minutes)

Hooks

  • content:update - Invalidates content cache
  • content:delete - Invalidates content cache
  • user:update - Invalidates user cache
  • auth:login - Invalidates user cache

Database Tools

The database tools plugin provides administrative utilities for database management and development.

Features

  • Migration Runner - Execute database migrations
  • Schema Browser - View tables, columns, and indexes
  • Query Console - Execute SQL queries directly
  • Table Inspector - View table data and statistics
  • Backup and Restore - Database backup utilities
  • Performance Metrics - Query performance analysis

Configuration

Plugin Configuration

API Endpoints

GET /admin/database/tables List all database tables

GET /admin/database/tables/:name View table schema and data

POST /admin/database/query Execute a SQL query

Execute Query

POST /admin/database/migrations/run Run pending migrations

GET /admin/database/migrations/status Check migration status

Services

Database Service

Admin Pages

  • /admin/database - Database dashboard
  • /admin/database/tables - Table browser
  • /admin/database/query - Query console
  • /admin/database/migrations - Migration manager

Seed Data Plugin

The seed data plugin generates sample data for development and testing purposes.

Features

  • Sample Content - Generate blog posts, pages, and articles
  • Test Users - Create user accounts with various roles
  • Media Files - Generate placeholder images and files
  • Collections - Populate custom collections with data
  • Relationships - Create related data (users, posts, comments)
  • Customizable - Configure data generation parameters

Configuration

Plugin Configuration

API Endpoints

POST /admin/seed-data/generate Generate seed data

Generate Seed Data

POST /admin/seed-data/clear Clear all seed data

GET /admin/seed-data/status Check seed data status

Usage

Seed Data Generation

Admin Pages

  • /admin/seed-data - Seed data generator interface

Next Steps

Was this page helpful?