30 lines
919 B
TypeScript
30 lines
919 B
TypeScript
import { Router } from 'express';
|
|
import { pluginConfig } from '../core/plugin-config';
|
|
import { authenticate } from '../middleware/auth';
|
|
import { authorize } from '../middleware/rbac';
|
|
|
|
const router = Router();
|
|
|
|
// Get Plugin Config
|
|
router.get('/:name/config', authenticate, authorize(['super_admin']), (req, res) => {
|
|
const { name } = req.params;
|
|
const config = pluginConfig.get(name);
|
|
// Mask secrets if needed? For now, super admin sees all.
|
|
res.json(config);
|
|
});
|
|
|
|
// Set Plugin Config
|
|
router.post('/:name/config', authenticate, authorize(['super_admin']), (req, res) => {
|
|
const { name } = req.params;
|
|
const config = req.body;
|
|
|
|
try {
|
|
pluginConfig.set(name, config);
|
|
res.json({ success: true, message: 'Configuração salva com sucesso' });
|
|
} catch (error) {
|
|
res.status(500).json({ error: 'Erro ao salvar configuração' });
|
|
}
|
|
});
|
|
|
|
export default router;
|