Skip to content

Commit

Permalink
fix(webhook-server): fix env var name conflict with k8s
Browse files Browse the repository at this point in the history
  • Loading branch information
Collinbrown95 committed Oct 19, 2023
1 parent 5ab5270 commit 8508f8f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion webhook-server/.env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Secret to verify JWT from GitHub webhook
WEBHOOK_SECRET=changeme
# Webhook server port
WEBHOOK_SERVER_PORT=3000
WEBHOOK_SERVER_PORT_NUMBER=3000
# NATS server
NATS_SERVER=localhost:4222
# NATS stream to publish events to
Expand Down
4 changes: 2 additions & 2 deletions webhook-server/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SMEE_URL := ${SMEE_URL}
WEBHOOK_SERVER_PORT := ${WEBHOOK_SERVER_PORT}
WEBHOOK_SERVER_PORT_NUMBER := ${WEBHOOK_SERVER_PORT_NUMBER}

forward-webhook:
smee --url $(SMEE_URL) --port $(WEBHOOK_SERVER_PORT)
smee --url $(SMEE_URL) --port $(WEBHOOK_SERVER_PORT_NUMBER)
7 changes: 4 additions & 3 deletions webhook-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'dotenv/config'
// Get config variables from environment
const {
WEBHOOK_SECRET,
WEBHOOK_SERVER_PORT,
WEBHOOK_SERVER_PORT_NUMBER,
NATS_SERVER,
NATS_PUB_STREAM
} = process.env
Expand All @@ -34,6 +34,7 @@ app.post('/', async (req, res) => {
// x-hub-signature-256 jwt that came with the request.
if (!verifySignature(req)) {
res.status(401).send("Unauthorized");
console.log("Unauthorized Request");
return;
}
// extract relevant information to put into queue.
Expand All @@ -50,6 +51,6 @@ app.post('/', async (req, res) => {
console.log("successfully published event: ", eventType)
})

app.listen(WEBHOOK_SERVER_PORT, () => {
console.log(`Webhook server listening on port ${WEBHOOK_SERVER_PORT}`)
app.listen(WEBHOOK_SERVER_PORT_NUMBER, () => {
console.log(`Webhook server listening on port ${WEBHOOK_SERVER_PORT_NUMBER}`)
})

0 comments on commit 8508f8f

Please sign in to comment.