23 lines
868 B
TypeScript
23 lines
868 B
TypeScript
import { PluginInstance, PluginContext } from '../../backend/src/core/types';
|
|
import { createLeadsRoutes } from './backend/routes';
|
|
import manifest from './manifest.json';
|
|
|
|
const plugin: PluginInstance = {
|
|
manifest: manifest as any,
|
|
async activate(ctx: PluginContext): Promise<void> {
|
|
const router = createLeadsRoutes(ctx);
|
|
ctx.app.use('/api/leads', router);
|
|
ctx.hooks.register('user:register', async (data: any) => {
|
|
await ctx.db('leads').insert({
|
|
user_id: data.userId,
|
|
source: 'registration',
|
|
status: 'new',
|
|
lead_type: 'member',
|
|
}).catch(() => { });
|
|
});
|
|
ctx.logger.info('Leads routes registered');
|
|
},
|
|
async deactivate(ctx: PluginContext): Promise<void> { ctx.logger.info('Leads deactivated'); },
|
|
};
|
|
export default plugin;
|