Library for Kitsas Addons. See also Template for Kitsas Addons and Kitsas Library
npm install --save kitsas-addon-library
import { KitsasAddon } from 'kitsas-addon-library';
const addon = new KitsasAddon({
appName: 'My Addon',
});
export default addon;
Options can be configured with AddonOptions or environment variables.
import addon from './addon';
import { AddonCall } from 'kitsas-addon-library';
import { Request, Response } from 'express';
const router = addon.createRouter('/addon');
router.get('/', async (req: Request, res: Response) => {
const call = new AddonCall(req);
const logs = await call.getLogs();
if (call.isActive()) {
res.render('main', { logs: logs });
} else {
res.render('introduction');
}
});
export default router;
Usually router handles get an AddonCall object containing information about the call and methods to interact with the Kitsas Server.
import addon from './addon';
import addonRouter from './addonRouter';
void addon.start([addonRouter]);
Remember to include all the routers in the start
call!