@novu/framework
Version:
The Code-First Notifications Workflow SDK.
2 lines (1 loc) • 2.77 kB
JavaScript
import{b as g,c as T,d as U}from"../chunk-CSADKVTU.js";import{a,b as n,h as V,ja as G}from"../chunk-LTQML2Z6.js";import{ConfigurableModuleBuilder as x}from"@nestjs/common";var{ConfigurableModuleClass:y,MODULE_OPTIONS_TOKEN:m,OPTIONS_TYPE:C,ASYNC_OPTIONS_TYPE:D}=new x().setClassMethodName("register").setFactoryMethodName("createNovuModuleOptions").setExtras(l=>({...l,isGlobal:!0})).build();var P="REGISTER_API_PATH";import{Controller as A,Req as c,Res as f,Inject as H,Get as q,Post as b,Options as w}from"@nestjs/common";import{Injectable as E,Inject as R}from"@nestjs/common";import{Injectable as I}from"@nestjs/common";var i=class{handler(e,r){return{body:()=>e.body,headers:t=>{let p=e.headers[t.toLowerCase()];return Array.isArray(p)?p[0]:p},method:()=>e.method||"GET",queryString:t=>{let p=e.query[t];return Array.isArray(p)?p[0]:p},url:()=>{let t=e.headers.host||"",p=t!=null&&t.includes("://")?"":`${e.protocol||"https"}://`;return new URL(e.originalUrl||e.url||"",`${p}${t||""}`)},transformResponse:({body:t,headers:p,status:h})=>(Object.entries(p).forEach(([N,S])=>{r.setHeader(N,S)}),r.status(h).send(t))}}};i=a([I()],i);var _="nest",u=class{constructor(e,r){this.options=e;this.novuHandler=r;this.novuRequestHandler=new T({frameworkName:_,...this.options,handler:this.novuHandler.handler})}async handleRequest(e,r){await this.novuRequestHandler.createHandler()(e,r)}};u=a([E(),n(0,R(m)),n(1,R(i))],u);var s=class{constructor(e){this.novuService=e}async handleGet(e,r){await this.novuService.handleRequest(e,r)}async handlePost(e,r){await this.novuService.handleRequest(e,r)}async handleOptions(e,r){await this.novuService.handleRequest(e,r)}};a([q(),n(0,c()),n(1,f())],s.prototype,"handleGet",1),a([b(),n(0,c()),n(1,f())],s.prototype,"handlePost",1),a([w(),n(0,c()),n(1,f())],s.prototype,"handleOptions",1),s=a([A(),n(0,H(u))],s);import{Module as Y}from"@nestjs/common";import{PATH_METADATA as M}from"@nestjs/common/constants";var O={provide:P,useFactory:l=>{if(!l.apiPath)throw new Error("`apiPath` must be provided to set the controller path");Reflect.defineMetadata(M,l.apiPath,s)},inject:[m]};function v(l,e=[]){return e.reduce((r,o)=>o(r),l)}var d=class extends y{static register(e,r){var t;let o=super.register(e);return o.controllers=[v(s,e.controllerDecorators||[])],(t=o.providers)==null||t.push(O,u,i,...r||[]),o.exports=[u,i],o}static registerAsync(e,r){var t;let o=super.registerAsync(e);return o.controllers=[s],(t=o.providers)==null||t.push(O,u,i,...r||[]),o.exports=[u,i],o}};d=a([Y({})],d);export{g as Client,V as CronExpression,m as NOVU_OPTIONS,u as NovuClient,s as NovuController,i as NovuHandler,d as NovuModule,T as NovuRequestHandler,P as REGISTER_API_PATH,_ as frameworkName,G as providerSchemas,O as registerApiPath,U as workflow};