You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a monorepo setup where Inngest functions live in a separate package, there's no solution to pass runtime configuration to functions.
apps
└── nextjs
└── app
└── api
└── inngest
└── route.tsx (serve is called there)
packages
└── inngest
└── functions
└── myfunction.ts
└── index.ts (middleware is setup here)
The Inngest package is a dependency of the Nextjs app. So it shouldn't import exported values from it since it will introduce cycle.
My proposed solution
I want to pass custom configuration data via serve to the client init function so I can set up the parametrized context. This follows the same context creation logic proposed by tRPC. Example from create-t3-turbo
// nextjs api routeimport{inngest}from"@acme/inngest"// custom package in monorepoimport{functions}from"@acme/inngest/functions"serve({client: inngest,
functions,ctx: inngest.createContext({myProp: "myValue"})})
// packages/inngestinterfaceInitialContext{myValue: string}consti=newInngest<InitialContext>({schemas: newEventSchemas().fromRecord<Events>()})constmiddleware=i.createMiddleware({name: "Test Middleware",// here come values from serveinit({ client, ctx }){return{
...
};};});exportconstinngest=i.use(middleware)
Describe alternatives you've considered
I considered accessing process.env.ENV_VAR directly in inngest package. This is suboptimal due to the lack of type safety. Also, this limits me only to process.env usage.
The text was updated successfully, but these errors were encountered:
In a monorepo setup where Inngest functions live in a separate package, there's no solution to pass runtime configuration to functions.
The Inngest package is a dependency of the Nextjs app. So it shouldn't import exported values from it since it will introduce cycle.
My proposed solution
I want to pass custom configuration data via serve to the client init function so I can set up the parametrized context. This follows the same context creation logic proposed by tRPC. Example from create-t3-turbo
Describe alternatives you've considered
I considered accessing process.env.ENV_VAR directly in inngest package. This is suboptimal due to the lack of type safety. Also, this limits me only to process.env usage.
The text was updated successfully, but these errors were encountered: