Skip to content

Commit 9e6ebae

Browse files
committed
test webhook
1 parent 11628df commit 9e6ebae

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"client": "npm run start --prefix client",
1414
"dev": "concurrently \"npm run server\" \"npm run client\" \"npm run webhook\"",
1515
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client",
16-
"webhook": "lt -p 5000 -s lairjgliargli"
16+
"webhook": "./sendgrid_webhook.sh"
1717
},
1818
"author": "",
1919
"license": "ISC",

server/routes/surveyRoutes.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ module.exports = app => {
1111
res.send('Thanks for voting!');
1212
});
1313

14+
app.post('/api/surveys/webhooks', (req, res) => {
15+
console.log(req.body);
16+
res.send({});
17+
});
18+
1419
app.post('/api/surveys', requireLogin, requireCredits, async (req, res) => {
1520
const { title, subject, body, recipients } = req.body;
1621

server/sendgrid_webhook.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
# make sure you have execute permissions:
3+
# cd /path/to/project
4+
# chmod +x ./sendgrid_webhook.sh
5+
# to run, type ./sendgrid_webhook.sh in the terminal
6+
7+
function localtunnel {
8+
lt -s lairjgliargli --port 5000
9+
}
10+
11+
until localtunnel; do
12+
echo "localtunnel server crashed"
13+
sleep 2
14+
done

0 commit comments

Comments
 (0)