If you want to add features to a service, you will need to register a plugin, which will be in the form of a standard Fastify plugin.
The config file will specify where the plugin file is located as the example below:
The path is relative to the config file path.
Since it uses fastify-sandbox under the hood, all other options of that package may be specified under the
You should export an async
function which receives a parameters
FastifyInstance) that is the main fastify instance
optsall the options specified in the config file after
Plugin file is being watched by
You don't need to reload Platformatic Service server while working on your plugin. Every time you save, the watcher will trigger a reload event and the server will auto-restart and load your updated code.
At this time, on Linux, file watch in subdirectories is not supported due to a Node.js limitation (documented here).
The path can also be a directory. In that case, the directory will be loaded with
Consider the following directory structure:
│ ├── foo
│ │ ├── something.js
│ │ └── bar
│ │ └── baz.js
│ ├── single-plugin
│ │ └── utils.js
│ └── another-plugin.js
By default the folder will be added as a prefix to all the routes defined within them. See the autoload documentation for all the options to customize this behavior.
Multiple plugins can be loaded in parallel by specifying an array: