Create base structure

This commit is contained in:
Ceda EI 2018-11-25 23:14:07 +05:30
parent 8d97415c4e
commit bd0a88c7dc
6 changed files with 27 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules/

0
bot.js Normal file
View File

10
server.js Normal file
View 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
View File

@ -0,0 +1,6 @@
const github = function (body) {
};
const gitlab = github;
module.exports = { github, gitlab };

6
util/convert/event.js Normal file
View 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
View File

@ -0,0 +1,4 @@
module.exports = {
getEvent: require('./event'),
commit: require('./commit'),
};