Skip to content

Commit

Permalink
trying out server
Browse files Browse the repository at this point in the history
  • Loading branch information
rofiesiiitp committed Jul 4, 2024
1 parent 62bfc9f commit 31c6fbf
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
ROFIES-GitHub.json
get-people/avatar_urls.txt
Contact Information ROFIES - Form Responses 1.csv
Contact Information ROFIES - Form Responses 1.csv
.vercel
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
{
"name": "webhook-server",
"version": "1.0.0",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"express": "^4.17.1",
"body-parser": "^1.19.0"
},
"devDependencies": {
"all-contributors-cli": "^6.26.1"
}
Expand Down
25 changes: 25 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const PORT = process.env.PORT || 3000;

app.use(bodyParser.json());

app.post('/webhook', (req, res) => {
const event = req.headers['x-github-event'];
const payload = req.body;

if (event === 'membership' && payload.action === 'added') {
const member = payload.member.login;
console.log(`🎉 Hello, @${member}! Welcome to ROFIES-IIITP GitHub organization!`);
console.log("🤖 We're thrilled to have you on board.");
console.log("🚀 Feel free to explore our projects and contribute your ideas.");
console.log("🌟 If you have any questions or need assistance, don't hesitate to reach out!");
}

res.status(200).send('Webhook received');
});

app.listen(PORT, () => {
console.log(`Server is listening on port ${PORT}`);
});

0 comments on commit 31c6fbf

Please sign in to comment.