diff options
| author | Adam Soltys <[email protected]> | 2021-06-10 17:24:14 -0400 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2021-06-10 17:24:14 -0400 |
| commit | fdbbb5af05c46a203032575a55ac66b655c801f1 (patch) | |
| tree | 0429fc249305da6e911a352591fac74191872bc7 | |
| parent | 421accbfbc0a1add93f7704e657ae93f2d836b82 (diff) | |
| download | coinos-server-fdbbb5af05c46a203032575a55ac66b655c801f1.tar.gz coinos-server-fdbbb5af05c46a203032575a55ac66b655c801f1.zip | |
remove build endpoint
| -rw-r--r-- | index.js | 68 |
1 files changed, 0 insertions, 68 deletions
@@ -70,7 +70,6 @@ require("./lib/notifications"); require("./lib/register"); require("./lib/send"); - require("./routes/assets"); require("./routes/invoices"); require("./routes/payments"); @@ -82,73 +81,6 @@ require("./routes/funding"); if (config.lnurl) require("./routes/lnurl"); if (config.imap) require("./lib/mail"); - -const sigHeaderName = "X-Hub-Signature-256"; -const sigHashAlg = "sha256"; -function verifyPostData(req, res, next) { - try { - if (!req.rawBody) { - return next("Request body empty"); - } - - const sig = Buffer.from(req.get(sigHeaderName) || "", "utf8"); - const hmac = crypto.createHmac(sigHashAlg, config.github); - const digest = Buffer.from( - sigHashAlg + "=" + hmac.update(req.rawBody).digest("hex"), - "utf8" - ); - - if (sig.length !== digest.length || !crypto.timingSafeEqual(digest, sig)) { - return next( - `Request body digest (${digest}) did not match ${sigHeaderName} (${sig})` - ); - } - } catch (e) { - console.log(e.message); - } - - return next(); -} - -app.post("/build", (req, res) => { - const mailgun = require("mailgun-js")(config.mailgun); - let data = { - subject: "Build started", - text: `Build started at ${new Date()}`, - from: "[email protected]", - to: "[email protected]" - }; - - mailgun.messages().send(data); - l.info("build starting"); - fs.writeFileSync("build.json", req.body.payload); - - const { exec } = require("child_process"); - exec("bash build.sh", (error, stdout, stderr) => { - if (error) { - data = { - subject: "Build error", - text: `Build failed at ${new Date()}`, - from: "[email protected]", - to: "[email protected]" - }; - - mailgun.messages().send(data); - l.warn("build failed"); - } else { - data = { - subject: "Build finished", - text: `Build finished at ${new Date()}`, - from: "[email protected]", - to: "[email protected]" - }; - - mailgun.messages().send(data); - l.info("build finished"); - } - }); -}); - app.use((err, req, res, next) => { const details = { path: req.path, |
