-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
28 lines (21 loc) · 879 Bytes
/
app.js
File metadata and controls
28 lines (21 loc) · 879 Bytes
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
require('dotenv').config()
const express = require('express');
const morgan = require('morgan');
const http = require('http');
const axios = require('axios').default;
const app = express();
app.use(morgan('dev'));
const PORT = process.env.PORT || 3000;
const trigger = async (req, res) => {
const url = 'https://api.github.com/repos/flockflair-dbit/acm-website/dispatches';
const headers = {
Accept: 'application/vnd.github+json',
Authorization: process.env.GITHUB_TOKEN,
};
const response = await axios({ url: url, method: 'POST', data: { event_type: 'webhook' }, headers: headers });
return res.status(200).json({ headers: response.headers, data: response.data, status: response.status });
}
// To test
app.get('/trigger', trigger)
app.post('/trigger', trigger)
app.listen(PORT, () => console.log(`Server Listening on port ${PORT}`));