Extending With Toolkit
Lucid provides a toolkit which allows you to programmatically call the client integration services within your application.
Custom Endpoint
When paired up with Fastify, you can create custom endpoints to better tailor Lucid to your needs. In the example bellow we are createing a custom endpoint to get a paginated list of documents that bellong to the page collection.
All services return errors as values giving you the flexibility to handle them as you see fit, however you can use the LucidAPIError
class to throw them to Lucid which will handle the error appropriately and return a formatted error response to the client.
Toolkit Services
Currently the toolkit only supports a handful of services, but none the less, this is still a very powerful feature.
Here is the list of what is currently supported:
Documents
In this example, the
fullSlug
filter would be a custom field that has been added to the page collection.
All available document column filters are prefixed with
document
as to hopefully not conflict with the custom field keys.
Locales
Returns all locales that have been configured in your
lucid.config.ts
file.
You can use first party templates, though more likley you will want to use a custom template which you can do by adding a
mjml
file in atemplates
directory at the root of your project. Learn more about mjml here.