37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
const express = require('express');
|
|
const router = express.Router();
|
|
const {
|
|
getConfigHandler,
|
|
saveConfigHandler,
|
|
createInstanceHandler,
|
|
deleteInstanceHandler,
|
|
getStatusHandler,
|
|
getQrHandler,
|
|
requestCodeHandler,
|
|
logoutHandler,
|
|
startHandler,
|
|
restartHandler,
|
|
handleWebhook,
|
|
} = require('../controllers/whatsappController');
|
|
const { protect, admin } = require('../middleware/authMiddleware');
|
|
|
|
// Public webhook (called by WAWP servers)
|
|
router.post('/webhook', handleWebhook);
|
|
|
|
// Admin-only: credentials config
|
|
router.get( '/config', protect, admin, getConfigHandler);
|
|
router.post('/config', protect, admin, saveConfigHandler);
|
|
|
|
// Admin-only: instance lifecycle
|
|
router.post('/create-instance', protect, admin, createInstanceHandler);
|
|
router.post('/delete-instance', protect, admin, deleteInstanceHandler);
|
|
|
|
// Admin-only: session management
|
|
router.get( '/status', protect, admin, getStatusHandler);
|
|
router.get( '/qr', protect, admin, getQrHandler);
|
|
router.post('/request-code', protect, admin, requestCodeHandler);
|
|
router.post('/logout', protect, admin, logoutHandler);
|
|
router.post('/start', protect, admin, startHandler);
|
|
router.post('/restart', protect, admin, restartHandler);
|
|
|
|
module.exports = router; |