UNPKG

meta-cloud-api

Version:
2 lines 1.14 kB
import {d,c}from'./chunk-JPGXONBQ.js';function b(h){let d$1=new d(h);return {webhook:async(e,r,i)=>{try{if(e.method==="GET"){let{"hub.mode":s,"hub.verify_token":n,"hub.challenge":t}=e.query,o=await d$1.processVerification(s||null,n||null,t||null);return Object.entries(o.headers).forEach(([a,l])=>{r.setHeader(a,l);}),r.status(o.status).send(o.body)}if(e.method==="POST"){let s=c(e.headers,e.url),n=new globalThis.Request(s,{method:e.method,headers:e.headers,body:JSON.stringify(e.body)}),t=await d$1.processWebhook(n);return Object.entries(t.headers).forEach(([o,a])=>{r.setHeader(o,a);}),r.status(t.status).send(t.body)}return r.status(405).json({error:"Method Not Allowed"})}catch(s){i(s);return}},flow:async(e,r,i)=>{try{let s=c(e.headers,e.url),n=new globalThis.Request(s,{method:e.method,headers:e.headers,body:e.method==="POST"?JSON.stringify(e.body):void 0}),t=await d$1.processFlow(n);return Object.entries(t.headers).forEach(([o,a])=>{r.setHeader(o,a);}),r.status(t.status).send(t.body)}catch(s){i(s);return}},processor:d$1}}export{b as a};//# sourceMappingURL=chunk-NOJFGTRT.js.map //# sourceMappingURL=chunk-NOJFGTRT.js.map