Endpoint Config
endpoint maps schema operations to HTTP requests. Endpoint config can be a single string or an operation map.
Endpoint shapes
TS
export const usersSchema = {
resource: "users",
endpoint: "/api/users"
} as const;TS
export const usersSchema = {
resource: "users",
endpoint: {
list: { url: "/api/users", method: "GET" },
detail: { url: "/api/users/:id", method: "GET" },
create: { url: "/api/users", method: "POST" },
update: { url: "/api/users/:id", method: "PATCH" },
delete: { url: "/api/users/:id", method: "DELETE" },
archive: { url: "/api/users/:id/archive", method: "POST" }
}
} as const;Endpoint object
| Property | Purpose |
|---|---|
url | Request URL. Supports :param placeholders. |
method | HTTP method. Defaults by operation when omitted. |
headers | Static request headers. |
query | Static query values merged with runtime query values. |
Default methods
| Operation | Default method |
|---|---|
create | POST |
update | PATCH |
delete | DELETE |
action | POST |
| Other operations | GET |
Identity placeholders
Endpoint placeholders are filled from identity.
TS
export const usersSchema = {
resource: "users",
identity: {
key: "uuid",
param: "userId"
},
endpoint: {
update: { url: "/api/users/:userId", method: "PATCH" }
}
} as const;For a row with { uuid: "u_123" }, the URL resolves to /api/users/u_123.
Query merge
Endpoint object query values are merged with runtime query values. Runtime values can override the same keys.
TS
endpoint: {
list: {
url: "/api/users",
method: "GET",
query: {
include: "role"
}
}
}Request body
The built-in endpoint provider sends values as the request body for non-GET and non-DELETE methods. Objects are serialized as JSON unless a Content-Type header is already provided. FormData, Blob, and string bodies are handled separately.
Common mistakes
- Keep backend business logic on the backend. Endpoint schema should describe request wiring only.
- Unresolved placeholders are left as
:paramtext in the URL. GETandDELETErequests do not receive a request body from the endpoint provider.