diff options
| author | Ran Guin <[email protected]> | 2021-05-13 22:08:52 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2021-06-09 16:05:08 -0700 |
| commit | 927e2c2bf398ad6ffd1c971abc7cabd9fa4f2059 (patch) | |
| tree | d1be2089c8a6d480287cd5a7950755a655af8e31 | |
| parent | e13425d8038bf15b38953079557dbba4ee988a3f (diff) | |
| download | coinos-server-927e2c2bf398ad6ffd1c971abc7cabd9fa4f2059.tar.gz coinos-server-927e2c2bf398ad6ffd1c971abc7cabd9fa4f2059.zip | |
add include referrals routes
| -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, |
