inngest / inngest-js

The developer platform for easily building reliable workflows with zero infrastructure for TypeScript & JavaScript
https://www.inngest.com/
GNU General Public License v3.0
440 stars 43 forks source link

Add `inngest.setEnvVars(env)` to set env vars late on the client #665

Closed jpwilliams closed 3 months ago

jpwilliams commented 3 months ago

Summary

On some platforms, environment variables are sent as a function argument and are not available as a global. serve() handlers manage this transparently as they can silently retrieve the values they are passed, but Inngest clients can require manual intervention.

For these cases, we add inngest.setEnvVars(), allowing you to set environment variables at runtime and rest any URLs or configuration that was set during instantiation.

app.on("GET", "/api/send-some-event", async (c) => {
  inngest.setEnvVars(c.env);

  await inngest.send({ name: "test/event/after" });

  return c.json({ message: "Done!" });
});

Checklist

Related

changeset-bot[bot] commented 3 months ago

🦋 Changeset detected

Latest commit: 6fc91b91d9710552cd0f16c3fca8c5a60cc88a56

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ------- | ----- | | inngest | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

inngest-release-bot commented 3 months ago

A user has added the prerelease/inngest label, so this PR will be published to npm with the tag pr-665. It will be updated with the latest changes as you push commits to this PR.

You can install this prerelease version with:

npm install inngest@pr-665

The last release was built and published from 6fc91b91d9710552cd0f16c3fca8c5a60cc88a56.