fastify-url-data

A plugin to provide access to the raw URL components

Showing:

Popularity

Downloads/wk

5.1K

GitHub Stars

33

Maintenance

Last Commit

6d ago

Contributors

19

Package

Dependencies

2

Size (min+gzip)

16.1KB

License

MIT

Type Definitions

Built-In

Tree-Shakeable

No?

Categories

Readme

fastify-url-data

CI NPM version Known Vulnerabilities js-standard-style

A plugin for Fastify that adds support for getting raw URL information from the request.

Example

const fastify = require('fastify')()

fastify.register(require('fastify-url-data'))

fastify.get('/foo', (req, reply) => {
  const urlData = req.urlData()
  req.log.info(urlData.path) // '/foo'
  req.log.info(urlData.query) // 'a=b&c=d'
  req.log.info(urlData.host) // '127.0.0.1'
  req.log.info(urlData.port) // 8080

  // if you just need single data:
  req.log.info(req.urlData('path')) // '/foo'

  reply.send({hello: 'world'})
})

// GET: 'http://127.0.0.1:8080/foo?a=b&c=d

License

Licensed under MIT

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100