inngest@2.6.0
·
895 commits
to main
since this release
Minor Changes
-
#202
21053edThanks @djfarrelly! - Add support for Fastify, either via a custom.route()or using a Fastify pluginimport Fastify from "fastify"; import inngestFastify, { serve } from "inngest/fastify"; import { functions, inngest } from "./inngest"; const fastify = Fastify({ logger: true, }); // The lead maintainer of Fastify recommends using this as a plugin: fastify.register(inngestFastify, { client: inngest, functions, options: {}, }); // We do also export `serve()` if you want to use it directly, though. fastify.route({ method: ["GET", "POST", "PUT"], handler: serve(inngest, functions), url: "/api/inngest", }); fastify.listen({ port: 3000 }, function (err, address) { if (err) { fastify.log.error(err); process.exit(1); } });
-
#298
4984aa8Thanks [@z.object({](https://github.com/z.object({), [@z.object({](https://github.com/z.object({)! - Add the ability to provide Zod schemas usingz.object()instead of requiring a record format// Previously we supported this new EventSchemas().fromZod({ "test.event": { data: z.object({ a: z.string() }), b: z.number() }), }, }); // Now we ALSO support this new EventSchemas().fromZod([ z.object({ name: z.literal("test.event"), data: z.object({ a: z.string() }), b: z.number() }), }), ]);
This should help if you wish to declare your events piece-by-piece instead of in a single object.
const firstEvent = z.object({ name: z.literal("app/user.created"), data: z.object({ id: z.string() }), }); const secondEvent = z.object({ name: z.literal("shop/product.deleted"), data: z.object({ id: z.string() }), }); new EventSchemas().fromZod([firstEvent, secondEvent]);
You can use the exported
LiteralZodEventSchematype to provide some autocomplete when writing your events, too.const ShopProductOrdered = z.object({ name: z.literal("shop/product.ordered"), data: z.object({ productId: z.string() }), }) satisfies LiteralZodEventSchema;