Overview
A multi-tenant Posts CMS built almost entirely with createCRUD - isolation fields, lifecycle notifications, and a custom soft-delete.
This example builds a small but realistic multi-tenant Content Management System for blog posts - using almost nothing but createCRUD. It shows how flexible the helper is in a real project.
What You'll Build
A posts API where:
- Multi-tenancy is handled with
isolationFieldsandthunder-core'swithTenant - Reads are public, writes are protected - anyone can read posts, only an authenticated tenant can create/update/delete
- An
afterCreatelifecycle hook fires a "new post" notification - A generated route (
del) is disabled and replaced with custom soft-delete logic - The full API is reviewed through generated OpenAPI docs
This example relies on thunder-core for authentication and tenancy. You'll install it during Setup.
Final Project Structure
posts.ts
post.ts
Steps
1. Setup
Initialize the project and add thunder-core.
2. Model
Define the multi-tenant post schema.
3. API
Generate the CRUD API with createCRUD.
4. Review
Inspect the API via OpenAPI and SDKs.
Comfortable with the basics? This example goes deeper than the Todo App. If createCRUD is new to you, read the createCRUD reference first.