Handler
Traditional HTTP frameworks expose endpoints. Handlers are Teo's HTTP endpoints.
The URL path of the handler
When working with HTTP requests, the requests are mapped into handlers with predefined rules.
When Teo's frontend packages are building a request url, they use a form of
/{server path prefix}/{namespacePaths}/{ModelName}/{actionName}
. For example,
to access findMany
on User
, we request this url: /User/findMany
.
Builtin auto-synthesized handlers
The builtin handlers supported by Teo are:
findUnique
find a unique objectfindMany
find many objectsfindFirst
find one objectcreate
create a new objectupdate
update an existing objectupsert
create an existing object if it doesn't existcopy
copy an existing object into a new onedelete
delete an existing objectcreateMany
create many objectsupdateMany
update many objectscopyMany
create many objects by copyingdeleteMany
delete many objectscount
count matched objectsaggregate
view statistics data on this modelgroupBy
view grouped statistics data on this model
Disabling auto-synthesized handlers
This feature is currently working in progress. We used to have this feature, but when we refactored our core in version 0.0.58, this feature is missing from the framework. We will add back this feature soon and update this documentation here.
Custom handler
Besides auto-synthesized handlers, developers can declare custom handlers with
the declare handler
syntax.
Non-api handler
Some of the handlers may return HTML pages, images or something else which
should not be exposed into Teo query client. Use the nonapi
keyword to
declare handlers of these types.
Custom handler group
Handlers can be declared directly in namespaces and models. It's great to group
APIs together. Use declare handler group
to declare a handler group to place
handlers of the same group. The handler group takes a part in the request URL
just like a model.
Handler implementation
To implement custom handlers, use server APIs. See:
- Namespace REFERENCE
- handler::Group REFERENCE
- Request REFERENCE
- Response REFERENCE