OrbisDB Plugins allow users to customize and enrich the behavior of their instance. This can be done by generating new streams, adding data to existing streams, validating them or doing actions after the stream has been processed.
OrbisDB Plugins are Javascript classes. They currently live in the server/plugins
folder and need to be added manually. Any dependencies are installed to the root OrbisDB folder.
OrbisDB Plugin architecture is a work in progress. There are plans to make Plugins isolated ES modules that can be installed using package managers, instead of being stored in the OrbisDB folder.
All plugins have at least 3 main files
server/plugins
plugin-name
settings.json
- Plugin’s metadata and settingsREADME.md
- additional information and usageindex.js
- main file used to load the pluginPlugins expose functionality based on hooks. There are currently 4 hook types
generate
- create new streams using the instance’s DID (ie. generating streams based on external triggers or data)validate
- check the stream details and decides whether or not it should be indexed (ie. token gating)add_metadata
- enhance the stream content before indexing, data is added under a namescoped key of a plugin_metadata
column (ie. resolving the author’s ENS)post_process
- perform actions after a stream has been indexed (ie. email notifications, webhook calls)Plugins can also expose API routes. These are added to the main Fastify instance and are namescoped to you Plugin’s ID.
Available HTTP methods that can be used are GET
, POST
, PUT
, PATCH
and DELETE
.
Plugins have to define a settings.json
file. These define the plugin’s ID, metadata, hook and route information as well as any dynamic variables.
Dynamic variables allow you to use user input inside your Plugin’s methods.