@symbiota2/sample-plugin v0.0.11
Symbiota2 Backend Plugin
A Symbiota2 backend plugin needs the following key features in order to work: this repository:
- One or more NestJS modules
- A single NestJS module exported as the default for the package via index.ts
- Each NestJS module is dynamic, with its imports for @symbiota/backend injected at runtime
Developing a plugin
- Clone this repository and add custom NestJS to src
- Export a single module as the default from index.ts
- Build the plugin project
npm run build
- Copy the
dist
directory toplugins
in the data directory of a Symbiota2 installation (and rename to something better thandist
) - Restart your Symbiota2 installation
- All controllers exported from the plugin's default module will be available within the Symbiota2 core back end
Symbiota2 backend plugins are built with WebPack, which bundles any
dependencies from @symbiota2/backend that the plugin will use. As a result,
plugins are pinned to a specific version of Symbiota2, and there is no guarantee
that an update to @symbiota2/backend will render the plugin compatible without
modification. For this reason, it is recommended that developers add a static,
readonly S2_VERSION to their default module,
and log the version in the register()
method. This method is required and
called each time the plugin is imported, so the plugin's Symbiota2 version
will always be displayed as Symbiota2 starts up. This will help administrators
track down bugs resulting from any incompatible plugins.
After a newly-built plugin has been copied to the ${APP_DATA_DIR}/plugins
directory and Symbiota2 has been restarted, Symbiota2 PluginModule scans the
plugin directory, searching for index.js
files and importing their default
exports. It is for this reason that the plugin must have a single, default
export.