Comparing version 0.8.4 to 0.8.5
{ | ||
"name": "inngest", | ||
"version": "0.8.4", | ||
"version": "0.8.5", | ||
"description": "Official SDK for Inngest.com", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -6,2 +6,18 @@ import { ServeHandler } from "./express"; | ||
* | ||
* Remix requires that you export both a "loader" for serving `GET` requests, | ||
* and an "action" for serving other requests, therefore exporting both is | ||
* required. | ||
* | ||
* See {@link https://remix.run/docs/en/v1/guides/resource-routes} | ||
* | ||
* @example | ||
* ```ts | ||
* import { serve } from "inngest/remix"; | ||
* import fns from "~/inngest"; | ||
* | ||
* const handler = serve("My Remix App", fns); | ||
* | ||
* export { handler as loader, handler as action }; | ||
* ``` | ||
* | ||
* @public | ||
@@ -8,0 +24,0 @@ */ |
45
remix.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.serve = void 0; | ||
const cross_fetch_1 = require("cross-fetch"); | ||
const zod_1 = require("zod"); | ||
@@ -22,2 +21,16 @@ const express_1 = require("./express"); | ||
return async ({ request: req, }) => { | ||
/** | ||
* If `Response` isn't included in this environment, it's probably a Node | ||
* env that isn't already polyfilling. In this case, we can polyfill it | ||
* here to be safe. | ||
*/ | ||
let Res; | ||
if (typeof Response === "undefined") { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-var-requires | ||
Res = require("cross-fetch").Response; | ||
} | ||
else { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
Res = Response; | ||
} | ||
const headers = { "x-inngest-sdk": this.sdkHeader.join("") }; | ||
@@ -32,3 +45,3 @@ let reqUrl; | ||
catch (err) { | ||
return new cross_fetch_1.Response(JSON.stringify(err), { | ||
return new Res(JSON.stringify(err), { | ||
status: 500, | ||
@@ -52,3 +65,3 @@ headers, | ||
const introspection = Object.assign(Object.assign({}, this.registerBody(reqUrl)), { devServerURL: (0, devserver_1.devServerUrl)((0, env_1.devServerHost)()).href, hasSigningKey: Boolean(this.signingKey) }); | ||
return new cross_fetch_1.Response(JSON.stringify(introspection), { | ||
return new Res(JSON.stringify(introspection), { | ||
status: 200, | ||
@@ -59,3 +72,3 @@ headers, | ||
// Grab landing page and serve | ||
return new cross_fetch_1.Response(landing_1.landing, { | ||
return new Res(landing_1.landing, { | ||
status: 200, | ||
@@ -68,3 +81,3 @@ headers: Object.assign(Object.assign({}, headers), { "content-type": "text/html; charset=utf-8" }), | ||
const { status, message } = await this.register(reqUrl, process.env[consts_1.envKeys.DevServerUrl]); | ||
return new cross_fetch_1.Response(JSON.stringify({ message }), { | ||
return new Res(JSON.stringify({ message }), { | ||
status, | ||
@@ -87,3 +100,3 @@ headers, | ||
if (stepRes.status === 500) { | ||
return new cross_fetch_1.Response(JSON.stringify(stepRes.error), { | ||
return new Res(JSON.stringify(stepRes.error), { | ||
status: stepRes.status, | ||
@@ -93,3 +106,3 @@ headers, | ||
} | ||
return new cross_fetch_1.Response(JSON.stringify(stepRes.body), { | ||
return new Res(JSON.stringify(stepRes.body), { | ||
status: stepRes.status, | ||
@@ -100,3 +113,3 @@ headers, | ||
} | ||
return new cross_fetch_1.Response(null, { status: 405, headers }); | ||
return new Res(null, { status: 405, headers }); | ||
}; | ||
@@ -109,2 +122,18 @@ } | ||
* | ||
* Remix requires that you export both a "loader" for serving `GET` requests, | ||
* and an "action" for serving other requests, therefore exporting both is | ||
* required. | ||
* | ||
* See {@link https://remix.run/docs/en/v1/guides/resource-routes} | ||
* | ||
* @example | ||
* ```ts | ||
* import { serve } from "inngest/remix"; | ||
* import fns from "~/inngest"; | ||
* | ||
* const handler = serve("My Remix App", fns); | ||
* | ||
* export { handler as loader, handler as action }; | ||
* ``` | ||
* | ||
* @public | ||
@@ -111,0 +140,0 @@ */ |
@@ -1,2 +0,2 @@ | ||
export declare const version = "0.8.4"; | ||
export declare const version = "0.8.5"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -5,3 +5,3 @@ "use strict"; | ||
// Generated by genversion. | ||
exports.version = "0.8.4"; | ||
exports.version = "0.8.5"; | ||
//# sourceMappingURL=version.js.map |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
363948
3646