0.0.3 • Published 4 years ago
@watched-com/sdk v0.0.3
@watched-com/sdk
WATCHED javascript addon SDK.
Create an addon
There are two ways to create addons.
1. With a class
import * as watched from '@watched-com/sdk';
watched.setup({
id: 'com.example.testserver',
name: 'WATCHED test server',
});
class MyAddon extends watched.Addon {
getProps() {
return {
type: 'worker',
id: 'com.example.sample.addon',
name: 'Sample Addon',
};
}
async directory(ctx, args) {
console.warn(ctx, args);
return { items: [] };
}
}
// Create addon instance, this also registers the addon
new MyAddon();
watched.start();
2. With functions
import * as watched from '@watched-com/sdk';
watched.setup({
id: 'com.example.testserver',
name: 'WATCHED test server',
});
watched
.createAddon({
type: 'worker',
id: 'com.example.sample.addon',
name: 'Sample Addon',
})
.on('directory', async (ctx, args) => {
console.warn(ctx, args);
return { items: [] };
});
watched.start();