-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
35 lines (30 loc) · 839 Bytes
/
app.js
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
29
30
31
32
33
34
35
const express = require("express");
const fs = require("fs");
const deployApp = require("./src/deploy");
const app = express();
app.use(express.static("public"));
app.use(express.json({ limit: "10mb" }));
const deploys = [];
app.post("/github/hook", (req, res) => {
console.log("req received");
console.log(req.body);
const { ref, repository } = req.body;
console.log("ref is", ref);
console.log("repository is ", repository);
if (
ref === "refs/heads/master" &&
repository.full_name === "garageScript/databases"
) {
deploys.push({
time: new Date(),
});
deployApp().then((result) => {
console.log("result is", result);
});
}
res.send("hello");
});
app.get("/github/stats", (req, res) => {
res.json(deploys);
});
app.listen(process.env.PORT || 3007); // hooks.learndatabases.dev