npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nest-inngest

v1.3.2

Published

Strongly typed Inngest module for Nest.js 💪😾

Downloads

983

Readme

nest-inngest

npm

An unofficial strongly typed Inngest module for Nest.js projects.

Overview

nest-inngest is a library designed for the Nest.js framework, allowing you to leverage all the benefits of the framework, such as Dependency Injection (DI).

Getting Started

Disclaimer: This guide serves as an example of how to use the nest-inngest library. The structure used in the examples is purely illustrative, and you are free to adapt it to your project's current structure.

  1. Install the library using your preferred package manager.

     pnpm add nest-inngest
  2. In your app.module.ts or a similar file, add a new item to the imports array.

    // app.module.ts
    import { Module } from "@nestjs/core";
    
    import { InngestModule } from "nest-inngest";
    
    import { inngest } from "../lib/inngest";
    
    @Module({
      imports: [
        InngestModule.forRoot({
          inngest,
          path: "/api/inngest",
        }),
      ],
      controllers: [],
      providers: [],
    })
    export class AppModule {}
  3. (Optional) In your inngest.ts file, include the schemas using your preferred method.

    // src/lib/inngest.ts
    import { Inngest, EventSchemas } from "inngest";
    import { NestInngest } from "nest-inngest";
    import { z } from "zod";
    
    export const inngest = new Inngest({
      id: "orders",
      // https://www.inngest.com/docs/reference/client/create#defining-event-payload-types
      schemas: new EventSchemas().fromZod({
        "orders/order.created": {
          data: z.object({
            id: z.string().uuid(),
            product: z.string(),
            quantity: z.number(),
          }),
        },
      }),
    });
    
    // instantiate and export Inngest helper decorator
    export const OrdersInngest = NestInngest.from(inngest);
  4. Assign a new Inngest function to your controller

    import { Controller } "@nestjs/common";
    import { NestInngest } from "nest-inngest";
    
    import { OrdersInngest } from "../lib/inngest"
    
    @Controller("orders")
    export class OrdersController {
       constructor(private readonly ordersService: OrdersService) {}
    
       @OrdersInngest.Function({
         id: "orders-handler"
       })
       @OrdersInngest.Trigger({
         event: "orders/order.created" // 👈 Type-safety
       })
       public async handleOrderCreated(
         { event, step }: NestInngest.context<typeof OrdersInngest, "orders/order.created"> // 👈 Type helper to function context
       ) {
         // process recently created order
    
         console.log(event.data);
    
         await this.ordersService.sendOrderNotification(event.data.id);
    
         return { success: true }
       }
    }
    

Roadmap

  • [x] Add a global Nest module using the .forRoot pattern.
  • [x] Export a class that accepts an instance of Inngest in the constructor and exposes typed decorators.
    • [x] Function decorator
    • [x] Trigger decorator
  • [x] Add typing helpers.
    • [x] Helper for typing the Context
  • [ ] Add automated tests.
  • [ ] Add automatic documentation in the AsyncAPI spec. (TBD)
  • [ ] Add Github actions with changelogs and auto releases