Files
clube67_newwhats.local/clube67/newwhats.local/plugins/SmartVision/index.ts
T
VPS 4 Deploy Agent 2f8c04a0a7
continuous-integration/webhook Falha no deploy de clube67_newwhats.local (VPS 4)
chore(ops): restore all source files in newwhats.clube67.com
2026-05-18 03:28:29 +02:00

36 lines
1.2 KiB
TypeScript

import { PluginInstance, PluginContext } from '../../backend/src/core/types';
import { ImageOptimizer } from './backend/Optimizer';
import manifest from './manifest.json';
const plugin: PluginInstance = {
manifest: manifest as any,
async activate(ctx: PluginContext): Promise<void> {
// Register for the upload:transform hook
ctx.hooks.register('upload:transform', async (payload: any) => {
const { buffer, mimetype, category } = payload;
// Only process common image formats
const imageTypes = ['image/jpeg', 'image/png', 'image/webp', 'image/avif'];
if (!imageTypes.includes(mimetype)) {
return null; // Skip non-images
}
ctx.logger.info(`[SmartVision] Optimizing image for category: ${category}`);
const result = await ImageOptimizer.optimize(buffer, category);
return {
buffer: result.buffer,
mimetype: result.mimetype
};
});
ctx.logger.info('SmartVision Optimizer activated');
},
async deactivate(ctx: PluginContext): Promise<void> {
ctx.logger.info('SmartVision Optimizer deactivated');
}
};
export default plugin;