counterfact 1.4.2 → 1.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -112,6 +112,8 @@ export class Dispatcher {
|
|
|
112
112
|
}
|
|
113
113
|
async request({ auth, body, headers = {}, method, path, query, req, }) {
|
|
114
114
|
debug(`request: ${method} ${path}`);
|
|
115
|
+
debug(`headers: ${JSON.stringify(headers)}`);
|
|
116
|
+
debug(`body: ${JSON.stringify(body)}`);
|
|
115
117
|
// If the incoming path includes the base path, remove it
|
|
116
118
|
if (this.openApiDocument?.basePath !== undefined &&
|
|
117
119
|
path.toLowerCase().startsWith(this.openApiDocument.basePath.toLowerCase())) {
|
|
@@ -128,6 +130,7 @@ export class Dispatcher {
|
|
|
128
130
|
if (body !== undefined && headers.contentType !== "application/json") {
|
|
129
131
|
throw new Error(`$.proxy() is currently limited to application/json requests. You tried to proxy to ${url} with a Content-Type of ${headers.contentType ?? "[unknown]"}. Please open an issue at https://github.com/pmcelhaney/counterfact/issues and prod me to fix this limitation.`);
|
|
130
132
|
}
|
|
133
|
+
delete headers.host;
|
|
131
134
|
const fetchResponse = await this.fetch(`${url}${req.path ?? ""}`, {
|
|
132
135
|
body: body === undefined ? undefined : JSON.stringify(body),
|
|
133
136
|
headers: new Headers(headers),
|
|
@@ -46,7 +46,7 @@ export function koaMiddleware(dispatcher, config, proxy = koaProxy) {
|
|
|
46
46
|
}
|
|
47
47
|
const response = await dispatcher.request({
|
|
48
48
|
auth,
|
|
49
|
-
body,
|
|
49
|
+
body: method === "HEAD" || method === "GET" ? undefined : body,
|
|
50
50
|
/* @ts-expect-error the value of a header can be an array and we don't have a solution for that yet */
|
|
51
51
|
headers,
|
|
52
52
|
method,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "counterfact",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "a library for building a fake REST API for testing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/app.js",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@changesets/cli": "2.29.6",
|
|
49
|
-
"@stryker-mutator/core": "9.
|
|
50
|
-
"@stryker-mutator/jest-runner": "9.
|
|
51
|
-
"@stryker-mutator/typescript-checker": "9.
|
|
52
|
-
"@swc/core": "1.13.
|
|
49
|
+
"@stryker-mutator/core": "9.1.1",
|
|
50
|
+
"@stryker-mutator/jest-runner": "9.1.1",
|
|
51
|
+
"@stryker-mutator/typescript-checker": "9.1.1",
|
|
52
|
+
"@swc/core": "1.13.5",
|
|
53
53
|
"@swc/jest": "0.2.39",
|
|
54
54
|
"@testing-library/dom": "10.4.1",
|
|
55
55
|
"@types/jest": "30.0.0",
|
|
@@ -71,15 +71,15 @@
|
|
|
71
71
|
"eslint-plugin-jest-dom": "5.5.0",
|
|
72
72
|
"eslint-plugin-no-explicit-type-exports": "0.12.1",
|
|
73
73
|
"eslint-plugin-prettier": "5.5.4",
|
|
74
|
-
"eslint-plugin-unused-imports": "4.
|
|
74
|
+
"eslint-plugin-unused-imports": "4.2.0",
|
|
75
75
|
"husky": "9.1.7",
|
|
76
|
-
"jest": "30.
|
|
76
|
+
"jest": "30.1.2",
|
|
77
77
|
"jest-retries": "1.0.1",
|
|
78
78
|
"node-mocks-http": "1.17.2",
|
|
79
79
|
"rimraf": "6.0.1",
|
|
80
80
|
"stryker-cli": "1.0.2",
|
|
81
81
|
"supertest": "7.1.4",
|
|
82
|
-
"tsd": "
|
|
82
|
+
"tsd": "0.33.0",
|
|
83
83
|
"using-temporary-files": "2.2.1"
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|