Comments (2)
It should be defined in FastifyReplyFromOptions but is missing there.
I am also wondering if it is implemented correct. I would expect that if i set options on registering the plugin than that they become the default settings for the actual reply.from call.
Current codebase is like this
const disableRequestLogging = opts.disableRequestLogging || false
fastify.decorateReply('from', function (source, opts) {
opts = opts || {}
const req = this.request.raw
const onResponse = opts.onResponse
const rewriteHeaders = opts.rewriteHeaders || headersNoOp
const rewriteRequestHeaders = opts.rewriteRequestHeaders || requestHeadersNoOp
const getUpstream = opts.getUpstream || upstreamNoOp
const onError = opts.onError || onErrorDefault
const retriesCount = opts.retriesCount || 0
const maxRetriesOn503 = opts.maxRetriesOn503 || 10
// And so on
I would have expected something like this:
const disableRequestLogging = opts.disableRequestLogging || false
const defaultOnResponse = opts.onResponse
const defaultRewriteHeaders = opts.onResonse || headersNoOp
const defaultGetUpstream = opts.getUpstream || upstreamNoOp
const defaultOnError = opts.onError || onErrorDefault
const defaultRetriesCount = opts.retriesCount || 0
const defaultMaxRetriesOn503 = opts.maxRetriesOn503 ?? 10
fastify.decorateReply('from', function (source, opts) {
opts || (opts = {})
const req = this.request.raw
const onResponse = opts.onResponse || defaultOnResponse
const rewriteHeaders = opts.rewriteHeaders || defaultRewriteHeaders
const rewriteRequestHeaders = opts.rewriteRequestHeaders || requestHeadersNoOp
const getUpstream = opts.getUpstream || defaultGetUpstream
const onError = opts.onError || defaultOnError
const retriesCount = opts.retriesCount ?? defaultRetriesCount
const maxRetriesOn503 = opts.maxRetriesOn503 ?? defaultMaxRetriesOn503
// And so on
In the current code you can not even set maxRetriesOn503 to 0 because of using || and not ??
I typed this comment with my phone so there can be typos in the code.
from fastify-reply-from.
if the implementation is not correct, I would love to see a test/repro to verify the problem.
@MaximeCheramy would you like to send a PR to add retriesCount
to the types? I think it should go to the @fastify/reply-from
module.
from fastify-reply-from.
Related Issues (20)
- Suggestion: rewriteHeaders should take originalReq as argument HOT 2
- Request type in onResponse option HOT 3
- Allow disabling request logging HOT 4
- Docs (potentially code) and Typescript definition not in sync HOT 2
- [Undici] Stream body support HOT 3
- ChainAlert: npm package release (6.7.0) has no matching tag in this repo
- Rewrite body HOT 4
- make use of global agent
- Header encoding changes, leading to `ERR_INVALID_CHAR` HOT 16
- Host and other request headers are incorrectly modified on the original request, not just the forwarded request HOT 3
- Option to disable request timeout HOT 2
- FastifyError [FST_REPLY_FROM_INTERNAL_SERVER_ERROR]: Connect Timeout Error HOT 4
- Odd behaviour in unit tests in disable-request-logging.test.js
- support pool for http2Requests HOT 3
- Update Documentation for multipart and reply-from interaction HOT 2
- Undici Body Timeout Error crashes fastify server HOT 5
- onResponse res instead of res.stream HOT 5
- False response errored messages HOT 5
- Pass the request to the queryString function HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastify-reply-from.