@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"
|
"@trigger.dev/sdk": "workspace:^2.2.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@remix-run/web-fetch": "^4.3.5",
|
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"express": "^4.18.2"
|
"express": "^4.18.2"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import express, { Express } from "express";
|
import express, { Express } from "express";
|
||||||
import { TriggerClient } from "@trigger.dev/sdk";
|
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.
|
* 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: nextHeaders, method } = req;
|
||||||
|
|
||||||
const headers = new StandardHeaders();
|
const headers = new Headers();
|
||||||
|
|
||||||
Object.entries(nextHeaders).forEach(([key, value]) => {
|
Object.entries(nextHeaders).forEach(([key, value]) => {
|
||||||
headers.set(key, value as string);
|
headers.set(key, value as string);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create a new Request object (hardcode the url because it doesn't really matter what it is)
|
// 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,
|
headers,
|
||||||
method,
|
method,
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
body: req.body ? JSON.stringify(req.body) : req,
|
body: req.body ? JSON.stringify(req.body) : req,
|
||||||
|
duplex: "half",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"declaration": false,
|
"declaration": false,
|
||||||
"declarationMap": false
|
"declarationMap": false,
|
||||||
|
"lib": ["DOM"]
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules"]
|
"exclude": ["node_modules"]
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
-34
@@ -858,7 +858,6 @@ importers:
|
|||||||
|
|
||||||
packages/express:
|
packages/express:
|
||||||
specifiers:
|
specifiers:
|
||||||
'@remix-run/web-fetch': ^4.3.5
|
|
||||||
'@trigger.dev/sdk': workspace:^2.2.2
|
'@trigger.dev/sdk': workspace:^2.2.2
|
||||||
'@trigger.dev/tsconfig': workspace:*
|
'@trigger.dev/tsconfig': workspace:*
|
||||||
'@types/debug': ^4.1.7
|
'@types/debug': ^4.1.7
|
||||||
@@ -869,7 +868,6 @@ importers:
|
|||||||
tsup: ^6.5.0
|
tsup: ^6.5.0
|
||||||
tsx: ^3.12.1
|
tsx: ^3.12.1
|
||||||
dependencies:
|
dependencies:
|
||||||
'@remix-run/web-fetch': 4.3.5
|
|
||||||
debug: 4.3.4
|
debug: 4.3.4
|
||||||
express: 4.18.2
|
express: 4.18.2
|
||||||
devDependencies:
|
devDependencies:
|
||||||
@@ -10875,32 +10873,12 @@ packages:
|
|||||||
- react-dom
|
- react-dom
|
||||||
dev: true
|
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:
|
/@remix-run/web-blob/3.0.5:
|
||||||
resolution: {integrity: sha512-Mungj3erqCrq0+5zU/34NkeC2g+U7K6Uwa8uNiZgANvw0Wc64wKglk4MPQJZA0Y2tgPYXyrRn7uw4q75j6Hhww==}
|
resolution: {integrity: sha512-Mungj3erqCrq0+5zU/34NkeC2g+U7K6Uwa8uNiZgANvw0Wc64wKglk4MPQJZA0Y2tgPYXyrRn7uw4q75j6Hhww==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@remix-run/web-stream': 1.0.4
|
'@remix-run/web-stream': 1.0.4
|
||||||
web-encoding: 1.1.5
|
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:
|
/@remix-run/web-fetch/4.3.6:
|
||||||
resolution: {integrity: sha512-ifadyJS+/7W6LhKyA8tIR9fBIPwLCFVpl1YCYg5i0ikykiXxE3IWtPVB1G51AJFghc1YgR7rq8BRJLsJeUbE5Q==}
|
resolution: {integrity: sha512-ifadyJS+/7W6LhKyA8tIR9fBIPwLCFVpl1YCYg5i0ikykiXxE3IWtPVB1G51AJFghc1YgR7rq8BRJLsJeUbE5Q==}
|
||||||
engines: {node: ^10.17 || >=12.3}
|
engines: {node: ^10.17 || >=12.3}
|
||||||
@@ -10918,23 +10896,11 @@ packages:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@remix-run/web-blob': 3.0.5
|
'@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:
|
/@remix-run/web-form-data/3.0.5:
|
||||||
resolution: {integrity: sha512-txXJDzjDuTxF8MFvEp9AA2HF3oPcvmlE1I/6HIxeGpX3vpBtrCPw5KQ/nzgBZNuAxyxEm8ps6Ds/UZwoDyfGsQ==}
|
resolution: {integrity: sha512-txXJDzjDuTxF8MFvEp9AA2HF3oPcvmlE1I/6HIxeGpX3vpBtrCPw5KQ/nzgBZNuAxyxEm8ps6Ds/UZwoDyfGsQ==}
|
||||||
dependencies:
|
dependencies:
|
||||||
web-encoding: 1.1.5
|
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:
|
/@remix-run/web-stream/1.0.4:
|
||||||
resolution: {integrity: sha512-SVO42pH21I1sAhksGEM8ZBV/jc1mz6knZSg6Qo/2HPy9JTvtUykm3QMHtF2OMCTUXxdRW+4E/rphkPRyGc8WKw==}
|
resolution: {integrity: sha512-SVO42pH21I1sAhksGEM8ZBV/jc1mz6knZSg6Qo/2HPy9JTvtUykm3QMHtF2OMCTUXxdRW+4E/rphkPRyGc8WKw==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
Reference in New Issue
Block a user