-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
35 lines (30 loc) · 922 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const bodyParser = require("body-parser");
const cors = require("cors");
const express = require("express");
const webhookHelper = require("./webhookController");
const app = express();
const port = 5000;
app.use(bodyParser.json());
app.use(bodyParser.text());
app.use(cors());
const processWebhook = (request) => {
const webhook = webhookHelper.decryptWebhookIfNeeded(request);
console.log(webhook);
switch (webhook.event) {
case "VERIFICATION_COMPLETED":
// Do logic here for VERIFICATION_COMPLETED event
break;
case "VERIFICATION_REVIEWED":
// Do logic here for VERIFICATION_REVIEWED event
break;
default:
console.log("Couldn't process webhook event");
}
};
app.post("/passbase-webhooks", (req, res) => {
processWebhook(req);
res.status(200).send("Success");
});
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});