mirror of
https://gitlab.com/ceda_ei/git-alerts-bot
synced 2025-05-09 15:46:54 +02:00
Create base structure
This commit is contained in:
parent
8d97415c4e
commit
bd0a88c7dc
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
node_modules/
|
10
server.js
Normal file
10
server.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const app = express();
|
||||||
|
app.use(express.json());
|
||||||
|
const convert = require('./util/convert');
|
||||||
|
|
||||||
|
app.get('/webhook/:provider', (req) => {
|
||||||
|
const strategy = req.params.provider;
|
||||||
|
const eventType = convert.getEvent[strategy](req.body);
|
||||||
|
});
|
||||||
|
app.listen(2000, () => console.log('Listening on port 2000'));
|
6
util/convert/commit.js
Normal file
6
util/convert/commit.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
const github = function (body) {
|
||||||
|
};
|
||||||
|
|
||||||
|
const gitlab = github;
|
||||||
|
|
||||||
|
module.exports = { github, gitlab };
|
6
util/convert/event.js
Normal file
6
util/convert/event.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
const github = function (body) {
|
||||||
|
if (body.commits && body.ref.match("^/refs/heads/") return "commit";
|
||||||
|
if (body.commits && body.ref.match("^/refs/tags/") return "tag";
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {github};
|
4
util/convert/index.js
Normal file
4
util/convert/index.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
module.exports = {
|
||||||
|
getEvent: require('./event'),
|
||||||
|
commit: require('./commit'),
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user