first commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
const notificationService = require('../services/notification.service');
|
||||
const responseHelper = require('../../../helpers/response.helper');
|
||||
|
||||
class NotificationController {
|
||||
static async handle(req, res) {
|
||||
const payload = req.body;
|
||||
|
||||
try {
|
||||
const isValid = notificationService.verifySignature(payload);
|
||||
if (!isValid) {
|
||||
return responseHelper.error(res, "Invalid Signature Key", 403);
|
||||
}
|
||||
|
||||
await notificationService.processNotification(payload);
|
||||
|
||||
return responseHelper.success(res, "Notification Handled");
|
||||
} catch (error) {
|
||||
console.error("Webhook Error:", error.message);
|
||||
return responseHelper.error(res, error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = NotificationController;
|
||||
Reference in New Issue
Block a user