@fastify/reply-from 7.0.0 → 7.0.1
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.
- package/.github/workflows/ci.yml +1 -1
- package/README.md +13 -13
- package/index.js +1 -1
- package/package.json +3 -3
- package/test/fastify-multipart-incompatibility.js +2 -2
- package/test/post-formbody.js +1 -1
package/.github/workflows/ci.yml
CHANGED
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# fastify
|
|
1
|
+
# @fastify/reply-from
|
|
2
2
|
|
|
3
3
|

|
|
4
|
-
[](https://www.npmjs.com/package/@fastify/reply-from)
|
|
5
5
|
[](https://snyk.io/test/github/fastify/fastify-reply-from)
|
|
6
6
|
[](https://coveralls.io/github/fastify/fastify-reply-from?branch=master)
|
|
7
7
|
[](https://standardjs.com/)
|
|
@@ -12,11 +12,11 @@ HTTP2 to HTTP is supported too.
|
|
|
12
12
|
## Install
|
|
13
13
|
|
|
14
14
|
```
|
|
15
|
-
npm i fastify
|
|
15
|
+
npm i @fastify/reply-from
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
## Compatibility with fastify
|
|
19
|
-
|
|
18
|
+
## Compatibility with @fastify/multipart
|
|
19
|
+
`@fastify/reply-from` and [`@fastify/multipart`](https://github.com/fastify/fastify-multipart) should not be registered as sibling plugins nor should they be registered in plugins which have a parent-child relationship.<br> The two plugins are incompatible, in the sense that the behavior of `@fastify/reply-from` might not be the expected one when the above-mentioned conditions are not respected.<br> This is due to the fact that `@fastify/multipart` consumes the multipart content by parsing it, hence this content is not forwarded to the target service by `@fastify/reply-from`.<br>
|
|
20
20
|
However, the two plugins may be used within the same fastify instance, at the condition that they belong to disjoint branches of the fastify plugins hierarchy tree.
|
|
21
21
|
|
|
22
22
|
## Usage
|
|
@@ -41,7 +41,7 @@ const proxy = Fastify({
|
|
|
41
41
|
logger: true
|
|
42
42
|
})
|
|
43
43
|
|
|
44
|
-
proxy.register(require('fastify
|
|
44
|
+
proxy.register(require('@fastify/reply-from'), {
|
|
45
45
|
base: 'http://localhost:3001/'
|
|
46
46
|
})
|
|
47
47
|
|
|
@@ -77,7 +77,7 @@ for http2 nor undici. To illustrate:
|
|
|
77
77
|
|
|
78
78
|
```js
|
|
79
79
|
const socketPath = require('querystring').escape('/run/http-daemon.socket')
|
|
80
|
-
proxy.register(require('fastify
|
|
80
|
+
proxy.register(require('@fastify/reply-from'), {
|
|
81
81
|
base: 'unix+http://${socketPath}/'
|
|
82
82
|
});
|
|
83
83
|
```
|
|
@@ -91,7 +91,7 @@ requests. Enabling this flag should guarantee
|
|
|
91
91
|
This flag could controls the settings of the undici client, like so:
|
|
92
92
|
|
|
93
93
|
```js
|
|
94
|
-
proxy.register(require('fastify
|
|
94
|
+
proxy.register(require('@fastify/reply-from'), {
|
|
95
95
|
base: 'http://localhost:3001/',
|
|
96
96
|
// default settings
|
|
97
97
|
undici: {
|
|
@@ -109,7 +109,7 @@ See undici own options for more configurations.
|
|
|
109
109
|
You can also pass the plugin a custom instance:
|
|
110
110
|
|
|
111
111
|
```js
|
|
112
|
-
proxy.register(require('fastify
|
|
112
|
+
proxy.register(require('@fastify/reply-from'), {
|
|
113
113
|
base: 'http://localhost:3001/',
|
|
114
114
|
undici: new undici.Pool('http://localhost:3001')
|
|
115
115
|
})
|
|
@@ -124,7 +124,7 @@ you can pass in [`agentOptions`](https://nodejs.org/api/http.html#http_new_agent
|
|
|
124
124
|
[`requestOptions`](https://nodejs.org/api/http.html#http_http_request_options_callback). To illustrate:
|
|
125
125
|
|
|
126
126
|
```js
|
|
127
|
-
proxy.register(require('fastify
|
|
127
|
+
proxy.register(require('@fastify/reply-from'), {
|
|
128
128
|
base: 'http://localhost:3001/',
|
|
129
129
|
http: {
|
|
130
130
|
agentOptions: { // pass in any options from https://nodejs.org/api/http.html#http_new_agent_options
|
|
@@ -139,7 +139,7 @@ proxy.register(require('fastify-reply-from'), {
|
|
|
139
139
|
|
|
140
140
|
You can also pass custom HTTP agents. If you pass the agents, then the http.agentOptions will be ignored. To illustrate:
|
|
141
141
|
```js
|
|
142
|
-
proxy.register(require('fastify
|
|
142
|
+
proxy.register(require('@fastify/reply-from'), {
|
|
143
143
|
base: 'http://localhost:3001/',
|
|
144
144
|
http: {
|
|
145
145
|
agents: {
|
|
@@ -160,7 +160,7 @@ You can either set `http2` to `true` or set the settings object to connect to a
|
|
|
160
160
|
The `http2` settings object has the shape of:
|
|
161
161
|
|
|
162
162
|
```js
|
|
163
|
-
proxy.register(require('fastify
|
|
163
|
+
proxy.register(require('@fastify/reply-from'), {
|
|
164
164
|
base: 'http://localhost:3001/',
|
|
165
165
|
http2: {
|
|
166
166
|
sessionTimeout: 10000, // HTTP/2 session timeout in msecs, defaults to 60000 (1 minute)
|
|
@@ -301,7 +301,7 @@ By default: 0 (disabled)
|
|
|
301
301
|
Override the `'Content-Type'` header of the forwarded request, if we are
|
|
302
302
|
already overriding the [`body`](#body).
|
|
303
303
|
|
|
304
|
-
### Combining with [fastify
|
|
304
|
+
### Combining with [@fastify/formbody](https://github.com/fastify/fastify-formbody)
|
|
305
305
|
|
|
306
306
|
`formbody` expects the body to be returned as a string and not an object.
|
|
307
307
|
Use the [`contentTypesToEncode`](#contentTypesToEncode) option to pass in `['application/x-www-form-urlencoded']`
|
package/index.js
CHANGED
|
@@ -166,7 +166,7 @@ module.exports = fp(function from (fastify, opts, next) {
|
|
|
166
166
|
|
|
167
167
|
fastify.addHook('onReady', (done) => {
|
|
168
168
|
if (isFastifyMultipartRegistered(fastify)) {
|
|
169
|
-
fastify.log.warn('fastify
|
|
169
|
+
fastify.log.warn('@fastify/reply-from might not behave as expected when used with @fastify/multipart')
|
|
170
170
|
}
|
|
171
171
|
done()
|
|
172
172
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastify/reply-from",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"description": "forward your HTTP request to another server, for fastify",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/fastify/fastify-reply-from#readme",
|
|
33
33
|
"devDependencies": {
|
|
34
|
+
"@fastify/formbody": "^6.0.0",
|
|
35
|
+
"@fastify/multipart": "^6.0.0",
|
|
34
36
|
"@sinonjs/fake-timers": "^9.0.0",
|
|
35
37
|
"@types/node": "^17.0.0",
|
|
36
38
|
"@types/tap": "^15.0.3",
|
|
37
39
|
"fastify": "^3.17.0",
|
|
38
|
-
"fastify-formbody": "^5.0.0",
|
|
39
|
-
"fastify-multipart": "^5.0.0",
|
|
40
40
|
"form-data": "^4.0.0",
|
|
41
41
|
"got": "^11.8.2",
|
|
42
42
|
"h2url": "^0.2.0",
|
|
@@ -5,7 +5,7 @@ const path = require('path')
|
|
|
5
5
|
const t = require('tap')
|
|
6
6
|
const Fastify = require('fastify')
|
|
7
7
|
const From = require('..')
|
|
8
|
-
const Multipart = require('fastify
|
|
8
|
+
const Multipart = require('@fastify/multipart')
|
|
9
9
|
const http = require('http')
|
|
10
10
|
const get = require('simple-get').concat
|
|
11
11
|
const FormData = require('form-data')
|
|
@@ -62,7 +62,7 @@ instance.listen(0, (err) => {
|
|
|
62
62
|
logStream.on('data', (log) => {
|
|
63
63
|
if (
|
|
64
64
|
log.level === 40 &&
|
|
65
|
-
log.msg.match(
|
|
65
|
+
log.msg.match(/@fastify\/reply-from might not behave as expected when used with @fastify\/multipart/)
|
|
66
66
|
) {
|
|
67
67
|
t.pass('incompatibility warn message logged')
|
|
68
68
|
}
|
package/test/post-formbody.js
CHANGED
|
@@ -10,7 +10,7 @@ const instance = Fastify()
|
|
|
10
10
|
instance.register(From, {
|
|
11
11
|
contentTypesToEncode: ['application/x-www-form-urlencoded']
|
|
12
12
|
})
|
|
13
|
-
instance.register(require('fastify
|
|
13
|
+
instance.register(require('@fastify/formbody'))
|
|
14
14
|
|
|
15
15
|
t.plan(9)
|
|
16
16
|
t.teardown(instance.close.bind(instance))
|