forked from inngest/next-pxci-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.ts
More file actions
34 lines (31 loc) · 853 Bytes
/
client.ts
File metadata and controls
34 lines (31 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Inngest, InngestMiddleware } from "inngest";
import { PrismaClient } from "@prisma/client";
// make Prisma available in the Inngest functions
const prismaMiddleware = new InngestMiddleware({
name: "Prisma Middleware",
init() {
const prisma = new PrismaClient();
return {
onFunctionRun(ctx) {
return {
transformInput(ctx) {
return {
// Anything passed via `ctx` will be merged with the function's arguments
ctx: {
prisma,
},
};
},
};
},
};
},
});
// Create a client to send and receive events
export const inngest = new Inngest({
id: "event-app",
keys: {
api: process.env.NEXT_INNGEST_API_KEY, // Ensure this matches your environment variable
},
middleware: [prismaMiddleware],
});