A plugin is a way to decouple logic into smaller parts, defining reusable components across the server.
Defining a plugin is as simple as defining a new Teakit instance:
Plugins can be registered by using use
method.
Registering a plugin will combine types between the plugin and current instance, and the scope of hooks and schema get merged as well.
Using the plugin pattern, you can define and decouple your logic into a separate file.
You can also define a function callback to inline the plugin.
Functional callback will allow a user to access main instance values like routes, schema, store, etc.
You can customize a plugin by creating a function to return callback which accepts Teakit.
Config type will be inferred into use
, generating auto completion and type strict as intend.
By default, Teakit will register any plugin and handle type definitions which when using multiple times will results in a multiple duplication of setting value or routes.
This can be fixed by providing name and optional seeds to help Teakit identify instance duplication:
You can find pre-built plugins for Application at plugins.