Core Concepts
/
Resources & the DSL
Resources & the DSL
Author your data model in TypeScript with the resource() DSL and typed field builders.
A resource is a named model scoped to an app. Its fields carry types, and those types are the schema — the compiler reads them directly rather than trusting a separate declaration.
1
import
{
resource
,
s
}
from
"rastack/define"
;
3
export
const
Airport
=
resource
(
"airports"
,
"airport"
,
{
4
code
:
s
.
string
({
maxLength
:
3
,
unique
:
true
}),
5
name
:
s
.
string
({
maxLength
:
120
}),
6
elevation
:
s
.
int
({
min
:
0
}),
7
active
:
s
.
boolean
({
default
:
true
}),
9
search
:
[
"code"
,
"name"
],
10
admin
:
{
listDisplay
:
[
"code"
,
"name"
]
},
The signature is resource(app, model, fields, options?). The first two arguments become the URL segments — /api/airports/v1/airport/ — and the field map defines the columns.
Every field comes from s.*. Scalars carry a __rastackScalar discriminant and their constraints come from the call arguments:
maxLength, unique, default
The fourth argument configures behaviour across every surface:
•
search — fields the changelist and API search over.
•
admin — how the record renders in the admin site (listDisplay, etc.).
✓ Tip
Prefer no DSL at all? The compiler can infer resources straight from plain TypeScript interfaces — see Interface-Driven Entities. Build with AI
Every page is available as clean Markdown for LLMs and coding agents. Point one at the files below to build on top of React API Stack.
React API Stack · alpha · built to scale to millions