Skip to content
A Fastify plugin to normalize the request and reply to Express request and response
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
express Initial release of this fastify plugin Apr 9, 2019
test Updated for Fastify version 2.x Apr 13, 2019
.editorconfig Initial release of this fastify plugin Apr 9, 2019
.gitignore
.npmignore Added sending coverage to coveralls Apr 9, 2019
.travis.yml Initial release of this fastify plugin Apr 9, 2019
README.md Updated for Fastify version 2.x Apr 13, 2019
create-app.js Initial release of this fastify plugin Apr 9, 2019
index.js
normalize-reply.js
normalize-request.js
package.json Updated to normalize changes made to request and response in middleware Apr 20, 2019

README.md

fastify-normalize-request-reply

Build Status Coverage Status Known Vulnerabilities

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, like swagger-stats, that was originally written for Express to be be utilized within Fastify.

Install

npm install --save fastify-normalize-request-reply

Usage

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 to production in a production environment. (process.env.NODE_ENV or development, 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. (weak by 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 - undefined by default)
  • json replacer: Varied : The replacer argument used by JSON.stringify. (N/A - undefined by default)
  • json spaces: Varied : The space argument used by JSON.stringify. This is typically set to the number of spaces to use to indent prettified JSON. (N/A - undefined by default)
  • jsonp callback name: String : Specifies the default JSONP callback name. (callback by default)
  • query parser: Varied : Disable query parsing by setting the value to false, or set the query parser to use either simple or extended or a custom query string parsing function. (extended by default)
  • subdomain offset: Number : The number of dot-separated parts of the host to remove to access subdomain. (2 by 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 - disabled by default)

Todo

  • Update to the next release version of Fastify 2.x - Complete
  • Update to be compatible with the next release version of Express 5.x middleware

License

Licensed under MIT

You can’t perform that action at this time.