Custom Endpoints
Conduit attempts to help you cut back on boilerplate code.
Besides offering support for optional auto-generated CRUD endpoints for your custom schemas,
it also provides the means for you to construct powerful functional endpoints,
allowing you to effortlessly operate on your backend without having to write any code whatsoever.
These endpoints are schema-based, meaning they make use of a specific schema's entries.
Both system and custom schemas are supported.
Creating Endpoints
Bring up the Admin Panel and navigate to the Database
section.
Then head to the Custom Endpoints
tab.
Let's show you around the place.
Here's a rundown of the base fields and options making up a custom endpoint:
Name
to be used as the endpoint's nameAuthenticated
defines whether endpoint requires user authenticationOperation
to be used for the endpointSchema
to be used for the endpoint
Find/Get
operations additionally offer the following options:
Paginated
defines whether endpoint should provide pagination (skip/limit)Sorted
defines whether results should be sorted
Upon selecting your request type, the page is updated with the appropriate sections to be used while defining your endpoint's behavior.
Inputs
If you wish to, you may conditionally operate on your data based on variable fields.
Here's what makes up an input:
Name
to be used while referring to this field in the followup sectionsType
specifies the type of the fieldLocation
defines whether the field should be a query, body or url paramArray
defines whether the field should be an arrayOptional
defines whether the field should be optional
Queries
You're going to have to specify at least one query condition for your endpoint.
Queries require a schema field to be compared against as well as a condition,
comparing that field to a specific value (or a set of values).
These values may be defined through any of the following:
System Values
are internal context values (middleware-dependent)Custom Values
may be provided during endpoint creation (hardcoded)Schema Fields
are existing fields from the target schemaInput Fields
are defined in theInputs
section
The SQL-style Like operator is also supported.
Query condition checks can be AND
ed or OR
ed.
They may also be nested however you see fit.
Assignments
While creating or updating a schema doc entry, you're going to have to specify the values for your schema fields.
Create
and Update/Edit
operations require that you specify all schema fields,
whereas Patch
ones let you partially update an existing schema document.
Assignment definitions include the following fields:
Schema Field
to be populatedAction
to be used for the operationAssignment Value
to be used while populating the field
A field may be populated through any of the following actions:
SET
populates the field with target assignment valueINCREMENT
increments the field by target assignment valueDECREMENT
decrements the field by target assignment valueAPPEND
appends the target assignment value to an array fieldREMOVE
removes the target assignment value from an array field
Similarly to how Queries
operate, assignment values may come from:
- request context
- inputs (specified in the Inputs section)
- custom values