UNPKG

@novu/framework

Version:

The Code-First Notifications Workflow SDK.

2 lines (1 loc) 1.55 kB
import{a as l,b as x,c,d as T}from"../chunk-ZF4VXELU.js";import{h as O,ja as q,ra as S}from"../chunk-YLCZR2QR.js";var m="next",N=o=>typeof o=="object"&&o!==null&&typeof o.setHeader=="function"&&typeof o.status=="function"&&typeof o.send=="function",A=o=>{let p=new c({frameworkName:m,...o,handler:(h,R,d)=>{let n=R,i=e=>{let t=typeof n.headers.get=="function"?n.headers.get(e):n.headers[e];return Array.isArray(t)?t[0]:t};return{body:()=>typeof n.json=="function"?n.json():n.body,headers:i,method:()=>h||n.method||"",queryString:(e,t)=>{var a;let r=((a=n.query)==null?void 0:a[e])||t.searchParams.get(e);return Array.isArray(r)?r[0]:r},url:()=>{let e;try{e=new URL(n.url)}catch{}if(e){let s=i("host");if(s){let u=new URL(s.includes("://")?s:`${e.protocol}//${s}`);e.protocol=u.protocol,e.host=u.host,e.port=u.port,e.username=u.username,e.password=u.password}return e}let t="https",r=i("host")||"";try{(process.env.NODE_ENV==="development"||process.env.NODE_ENV==="dev")&&(t="http")}catch{}return new URL(n.url,`${t}://${r}`)},transformResponse:({body:e,headers:t,status:r})=>{if(N(d)){Object.entries(t).forEach(([s,u])=>{d.setHeader(s,u)}),d.status(r).send(e);return}let a=l();return new a(e,{status:r,headers:t})}}}}).createHandler(),f=p.bind(null,void 0);return Object.defineProperties(f,{GET:{value:p.bind(null,"GET")},POST:{value:p.bind(null,"POST")},OPTIONS:{value:p.bind(null,"OPTIONS")}})};export{x as Client,O as CronExpression,c as NovuRequestHandler,S as SeverityLevelEnum,m as frameworkName,q as providerSchemas,A as serve,T as workflow};