@trigger.dev/express: Remove web-fetch dependency and use native node Request/Response
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@trigger.dev/express": patch
|
||||
---
|
||||
|
||||
Remove web-fetch dependency and use native node Request/Response
|
||||
@@ -36,7 +36,6 @@
|
||||
"@trigger.dev/sdk": "workspace:^2.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@remix-run/web-fetch": "^4.3.5",
|
||||
"debug": "^4.3.4",
|
||||
"express": "^4.18.2"
|
||||
},
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import express, { Express } from "express";
|
||||
import { TriggerClient } from "@trigger.dev/sdk";
|
||||
import { Request as StandardRequest, Headers as StandardHeaders } from "@remix-run/web-fetch";
|
||||
|
||||
/**
|
||||
* This is a convenience function to create an express server for the TriggerClient. If you want to use Trigger.dev with an existing express server, use `createMiddleware` instead.
|
||||
@@ -92,20 +91,21 @@ export function createMiddleware(client: TriggerClient, path: string = "/api/tri
|
||||
};
|
||||
}
|
||||
|
||||
function convertToStandardRequest(req: express.Request): StandardRequest {
|
||||
function convertToStandardRequest(req: express.Request): Request {
|
||||
const { headers: nextHeaders, method } = req;
|
||||
|
||||
const headers = new StandardHeaders();
|
||||
const headers = new Headers();
|
||||
|
||||
Object.entries(nextHeaders).forEach(([key, value]) => {
|
||||
headers.set(key, value as string);
|
||||
});
|
||||
|
||||
// Create a new Request object (hardcode the url because it doesn't really matter what it is)
|
||||
return new StandardRequest("https://express.js/api/trigger", {
|
||||
return new Request("https://express.js/api/trigger", {
|
||||
headers,
|
||||
method,
|
||||
// @ts-ignore
|
||||
body: req.body ? JSON.stringify(req.body) : req,
|
||||
duplex: "half",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"declaration": false,
|
||||
"declarationMap": false
|
||||
"declarationMap": false,
|
||||
"lib": ["DOM"]
|
||||
},
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
||||
Generated
-34
@@ -858,7 +858,6 @@ importers:
|
||||
|
||||
packages/express:
|
||||
specifiers:
|
||||
'@remix-run/web-fetch': ^4.3.5
|
||||
'@trigger.dev/sdk': workspace:^2.2.2
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/debug': ^4.1.7
|
||||
@@ -869,7 +868,6 @@ importers:
|
||||
tsup: ^6.5.0
|
||||
tsx: ^3.12.1
|
||||
dependencies:
|
||||
'@remix-run/web-fetch': 4.3.5
|
||||
debug: 4.3.4
|
||||
express: 4.18.2
|
||||
devDependencies:
|
||||
@@ -10875,32 +10873,12 @@ packages:
|
||||
- react-dom
|
||||
dev: true
|
||||
|
||||
/@remix-run/web-blob/3.0.4:
|
||||
resolution: {integrity: sha512-AfegzZvSSDc+LwnXV+SwROTrDtoLiPxeFW+jxgvtDAnkuCX1rrzmVJ6CzqZ1Ai0bVfmJadkG5GxtAfYclpPmgw==}
|
||||
dependencies:
|
||||
'@remix-run/web-stream': 1.0.4
|
||||
web-encoding: 1.1.5
|
||||
dev: false
|
||||
|
||||
/@remix-run/web-blob/3.0.5:
|
||||
resolution: {integrity: sha512-Mungj3erqCrq0+5zU/34NkeC2g+U7K6Uwa8uNiZgANvw0Wc64wKglk4MPQJZA0Y2tgPYXyrRn7uw4q75j6Hhww==}
|
||||
dependencies:
|
||||
'@remix-run/web-stream': 1.0.4
|
||||
web-encoding: 1.1.5
|
||||
|
||||
/@remix-run/web-fetch/4.3.5:
|
||||
resolution: {integrity: sha512-cLLeNLvLRyFRhJLulzS98bb07kJ+ENkGaqUkBisdG4FNEoZF6tXtrTGLWJNJa1nAP/wFkMKEDxIP77LgAPyeow==}
|
||||
engines: {node: ^10.17 || >=12.3}
|
||||
dependencies:
|
||||
'@remix-run/web-blob': 3.0.4
|
||||
'@remix-run/web-form-data': 3.0.4
|
||||
'@remix-run/web-stream': 1.0.3
|
||||
'@web3-storage/multipart-parser': 1.0.0
|
||||
abort-controller: 3.0.0
|
||||
data-uri-to-buffer: 3.0.1
|
||||
mrmime: 1.0.1
|
||||
dev: false
|
||||
|
||||
/@remix-run/web-fetch/4.3.6:
|
||||
resolution: {integrity: sha512-ifadyJS+/7W6LhKyA8tIR9fBIPwLCFVpl1YCYg5i0ikykiXxE3IWtPVB1G51AJFghc1YgR7rq8BRJLsJeUbE5Q==}
|
||||
engines: {node: ^10.17 || >=12.3}
|
||||
@@ -10918,23 +10896,11 @@ packages:
|
||||
dependencies:
|
||||
'@remix-run/web-blob': 3.0.5
|
||||
|
||||
/@remix-run/web-form-data/3.0.4:
|
||||
resolution: {integrity: sha512-UMF1jg9Vu9CLOf8iHBdY74Mm3PUvMW8G/XZRJE56SxKaOFWGSWlfxfG+/a3boAgHFLTkP7K4H1PxlRugy1iQtw==}
|
||||
dependencies:
|
||||
web-encoding: 1.1.5
|
||||
dev: false
|
||||
|
||||
/@remix-run/web-form-data/3.0.5:
|
||||
resolution: {integrity: sha512-txXJDzjDuTxF8MFvEp9AA2HF3oPcvmlE1I/6HIxeGpX3vpBtrCPw5KQ/nzgBZNuAxyxEm8ps6Ds/UZwoDyfGsQ==}
|
||||
dependencies:
|
||||
web-encoding: 1.1.5
|
||||
|
||||
/@remix-run/web-stream/1.0.3:
|
||||
resolution: {integrity: sha512-wlezlJaA5NF6SsNMiwQnnAW6tnPzQ5I8qk0Y0pSohm0eHKa2FQ1QhEKLVVcDDu02TmkfHgnux0igNfeYhDOXiA==}
|
||||
dependencies:
|
||||
web-streams-polyfill: 3.2.1
|
||||
dev: false
|
||||
|
||||
/@remix-run/web-stream/1.0.4:
|
||||
resolution: {integrity: sha512-SVO42pH21I1sAhksGEM8ZBV/jc1mz6knZSg6Qo/2HPy9JTvtUykm3QMHtF2OMCTUXxdRW+4E/rphkPRyGc8WKw==}
|
||||
dependencies:
|
||||
|
||||
Reference in New Issue
Block a user