octoper / qwik-inngest-js

Serverless event-driven systems, background jobs, and scheduled jobs for TypeScript & JavaScript

Home Page:https://www.inngest.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool




Serverless event-driven queues, background jobs, and scheduled jobs for Typescript.
Works with any framework and platform.

Read the documentation and get started in minutes.


Inngest allows you to:

  • πŸ‘‰ Write background jobs in any framework, on any platform
  • πŸ‘‰ Create scheduled & cron jobs for any serverless platform
  • πŸ‘‰ Build serverless queues without configuring infra
  • πŸ‘‰ Write complex step functions anywhere
  • πŸ‘‰ Build serverless event-driven systems
  • πŸ‘‰ Reliably respond to webhooks, with retries & payloads stored for history

πŸ‘‹ Have a question or feature request? Join our Discord!


Getting started Β· Features Β· Contributing Β· Documentation


Getting started


Install Inngest:

npm install inngest  # or yarn add inngest

Writing functions

Write serverless functions and background jobs right in your own code:

import { Inngest } from "inngest";

const inngest = new Inngest({ name: "My App" });

// This function will be invoked by Inngest via HTTP any time
// the "app/user.signup" event is sent to to Inngest
export default inngest.createFunction(
  { name: "User onboarding communication" },
  { event: "app/user.signup" },
  async ({ event, step }) => {
    await step.run("Send welcome email", async () => {
      await sendEmail({
        email: event.data.email,
        template: "welcome",
      });
    });
  }
);
  • Functions are triggered by events which can be sent via this SDK, webhooks, integrations, or with a simple HTTP request.
  • When a matching event is received, Inngest invokes the function automatically, with built-in retries.

Serving your functions

Inngest invokes functions via HTTP, so you need to serve them using an adapter for the framework of your choice. See all frameworks here in our docs. Here is an example using the Next.js serve handler:

// /pages/api/inngest.ts
import { Inngest } from "inngest";
// See the "inngest/next" adapter imported here:
import { serve } from "inngest/next";
import myFunction from "../userOnboardingCOmmunication"; // see above function

// You can create this in a single file and import where it's needed
const inngest = new Inngest({ name: "My App" });

// Securely serve your Inngest functions for remote invocation:
export default serve(inngest, [myFunction]);

Sending events to trigger functions

// Send events
import { Inngest } from "inngest";
const inngest = new Inngest({ name: "My App" });

// This will run the function above automatically, in the background
inngest.send("app/user.signup", {
  data: { email: "text@example.com", user_id: "12345" },
});
  • Events can trigger one or more functions automatically, enabling you to fan-out work.
  • Inngest stores a history of all events for observability, testing, and replay.

Features

  • Fully serverless: Run background jobs, scheduled functions, and build event-driven systems without any servers, state, or setup
  • Works with your framework: Works with Next.js, Redwood, Express, Cloudflare Pages, Nuxt, Fresh (Deno), and Remix
  • Deploy anywhere: Keep deploying to your existing platform: Vercel, Netlify, Cloudflare, Deno, Digital Ocean, etc.
  • Use your existing code: Write functions within your current project and repo
  • Fully typed: Event schemas, versioning, and governance out of the box
  • Observable: A full UI for managing and inspecting your functions

Contributing

Clone the repository, then:

yarn # install dependencies
yarn dev # build/lint/test

We use Volta to manage Node/Yarn versions.

When making a pull request, make sure to commit the changed etc/inngest.api.md file; this is a generated types/docs file that will highlight changes to the exposed API.

Locally linking (npm|yarn link)

In order to provide sensible namespaced imports such as "inngest/next", the package actually builds to and deploys from dist/.

To replicate this locally to test changes with other local repos, you can link the project like so (replace npm for yarn if desired):

# in this repo
yarn build
yarn prelink
cd dist/
yarn link
# in another repo
yarn link inngest

About

Serverless event-driven systems, background jobs, and scheduled jobs for TypeScript & JavaScript

https://www.inngest.com/

License:GNU General Public License v3.0


Languages

Language:TypeScript 98.3%Language:JavaScript 1.7%