Skip to main content

Dynamic REST Engine

The core of Rotifex. Reads schema.json, creates SQLite tables, and registers five CRUD routes per model — all at startup and live when models are added via the admin API.

Use case: A developer defines a Product model with name, price, and in_stock fields. Rotifex immediately exposes /api/products with full CRUD, filtering, sorting, and pagination — no restart needed.

How It Works

  1. schema.json is parsed by schemaLoader.js into normalized model definitions.
  2. tableSync.js runs CREATE TABLE IF NOT EXISTS for each model.
  3. routeFactory.js registers generic parametric routes (/api/:table) that resolve the model from an in-memory store at request time.
  4. When a model is added/removed via the admin API, the in-memory store is updated and routes resolve immediately.

Field Types

Schema TypeSQLite TypeNotes
stringTEXT
numberREALFloat
integerINTEGER
booleanINTEGERStored as 0/1

Field Definition Formats

// Shorthand
{ "name": "string" }

// Full form
{
"name": {
"type": "string",
"required": true,
"unique": false,
"default": "Unnamed"
}
}

Auto-Generated Columns

Every model automatically gets:

  • id — UUID primary key
  • created_at — ISO 8601 timestamp
  • updated_at — ISO 8601 timestamp (updated on every PUT)

Table Naming

Model names are lowercased and pluralized:

  • Product → table products → route /api/products
  • Order → table orders → route /api/orders