Deploy: 2026-05-21 18:06:46

This commit is contained in:
Hamza-Ayed
2026-05-21 18:06:46 +03:00
parent 71cef1de1d
commit a411acbdf6
3 changed files with 24 additions and 9 deletions

View File

@@ -28,11 +28,20 @@ app.use(express.json());
const PORT = process.env.PORT || 3722;
// Health check endpoint
// Health check endpoint (Public)
app.get('/health', (req, res) => {
res.json({ status: 'healthy', service: 'Nabeh WhatsApp Gateway' });
});
// Security Middleware: Protect all /api/ routes
app.use('/api', (req, res, next) => {
const secret = req.header('X-Webhook-Secret');
if (!process.env.WEBHOOK_SECRET || secret !== process.env.WEBHOOK_SECRET) {
return res.status(403).json({ error: 'Unauthorized gateway access' });
}
next();
});
// Start or retrieve a session
app.post('/api/sessions/start', async (req, res) => {
const { session_key, webhook_url } = req.body;