dsql-admin/dsql-app/.local_dist/server/pages/api/webhooks/github-push.js
Benjamin Toby 885c11f674 Updates
2025-01-14 07:42:13 +01:00

1 line
2.0 KiB
JavaScript

"use strict";(()=>{var e={};e.id=5122,e.ids=[5122],e.modules={75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},33873:e=>{e.exports=require("path")},96762:(e,t)=>{Object.defineProperty(t,"M",{enumerable:!0,get:function(){return function e(t,o){return o in t?t[o]:"then"in t&&"function"==typeof t.then?t.then(t=>e(t,o)):"function"==typeof t&&"default"===o?t:void 0}}})},61660:(e,t,o)=>{o.r(t),o.d(t,{config:()=>h,default:()=>P,routeModule:()=>A});var n={};o.r(n),o.d(n,{default:()=>g});var r=o(89947),s=o(2706),i=o(96762),u=o(33873),a=o.n(u),l=o(29021),d=o.n(l),c=o(55511);let p=process.env.DSQL_GITHUB_WEBHOOK_SECRET||"",f=e=>{console.log(e.headers);let t=(0,c.createHmac)("sha256",p).update(JSON.stringify(e.body)).digest("hex");return console.log(t),`sha256=${t}`===e.headers["x-hub-signature-256"]};async function g(e,t){if("POST"!==e.method)return t.json({msg:"Failed!"});if(!f(e)){console.log("Authorization failed"),t.status(401).send("Unauthorized");return}let o=e.body;try{console.log("Request Recieved");let e=o.ref;if(!e?.match(/main/)){console.log("Not Main Branch"),t.json({success:!0});return}d().writeFileSync(a().resolve(process.cwd(),"./.dist","REDEPLOY_FLAG"),String(Date.now()),"utf-8"),console.log("Deploy Flag Triggered. Now Redeploying ..."),t.json({success:!0})}catch(e){console.log(e),t.json({msg:"Not Handled Yet"})}}let P=(0,i.M)(n,"default"),h=(0,i.M)(n,"config"),A=new r.PagesAPIRouteModule({definition:{kind:s.A.PAGES_API,page:"/api/webhooks/github-push",pathname:"/api/webhooks/github-push",bundlePath:"",filename:""},userland:n})},2706:(e,t)=>{Object.defineProperty(t,"A",{enumerable:!0,get:function(){return o}});var o=function(e){return e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE",e}({})},89947:(e,t,o)=>{e.exports=o(75600)}};var t=require("../../../webpack-api-runtime.js");t.C(e);var o=t(t.s=61660);module.exports=o})();