fastify-normalize-request-reply v2.2.1
fastify-normalize-request-reply
NOTE
This plugin will not be updated for version Fastify 3.x, because of the internal changes that where made for how middleware is implemented in Fastify now.
NOTE
This plugin does not support Express middleware that goes beyond simple request and response interaction. If the Express middleware has a UI with a template engine view; utilizes the Express routers; or starts its own instance of Express, then it is not supported.
Description
A plugin for Fastify version 2.x that utilizes the Hook onRequest with addHook to normalize the Fastify request and reply to the Express version 4.x request and response. This allows middleware with interaction with the request and response that was originally written for Express to be be utilized within Fastify.
Install
npm install --save fastify-normalize-request-replyUsage
Add it to you project with register and you are done!
// Register the plugin
fastify.register(require('fastify-normalize-request-reply'));Options
This plugin allows specifying options that are normally available to the Express request and response through Application Settings:
env: String : Environment mode. Be sure to set toproductionin a production environment. (process.env.NODE_ENVordevelopment, if NODE_ENV environment variable is not set, by default)etag: Varied : Set the ETag response header. For possible values, see the etag options table. (weakby default)json escape: Boolean : Enable escaping JSON responses from the res.json, res.jsonp, and res.send APIs. This will escape the characters <, >, and & as Unicode escape sequences in JSON. (N/A - undefinedby default)json replacer: Varied : Thereplacerargument used byJSON.stringify. (N/A - undefinedby default)json spaces: Varied : Thespaceargument used byJSON.stringify. This is typically set to the number of spaces to use to indent prettified JSON. (N/A - undefinedby default)jsonp callback name: String : Specifies the default JSONP callback name. (callbackby default)query parser: Varied : Disable query parsing by setting the value tofalse, or set the query parser to use eithersimpleorextendedor a custom query string parsingfunction. (extendedby default)subdomain offset: Number : The number of dot-separated parts of the host to remove to access subdomain. (2by default)trust proxy: Varied : Indicates the server is behind a front-facing proxy, and to use the X-Forwarded-* headers to determine the connection and the IP address of the client. To enable it, use the values described in the trust proxy options table. (false - disabledby default)
License
Licensed under MIT