Plugins allow you to implement your own endpoints, aggregators or preservers for the Amadeus project.
To create a plugin run:
npm install @amadeus-music/core @amadeus-music/util
npm install -D vite
Note that
@amadeus-music/util
package is optional, but might be useful for your plugin development.
Now add a build script to your package.json
:
"scripts": {
"build": "vite build -c node_modules/@amadeus-music/core/plugin.config.cjs"
},
To start developing your plugin create an index.ts
file and register your plugin there:
import { register } from "@amadeus-music/core";
import { name, version } from "./package.json";
const { ... } = register({ name, version });
register
function returns an sdk bound to your plugin. A simple use case would be:
import { register } from "@amadeus-music/core";
import { name, version } from "./package.json";
const { init, stop, info } = register({ name, version });
init((config) => {
info(`Plugin initialized with ${JSON.stringify(config)}!`);
});
stop(() => {
info("Plugin stopped!");
});
Note that
@amadeus-music/core
reexports everything from libfun and superstruct as these are common shared dependencies.
Amadeus plugin system uses pools to manage events for your plugin.