Nefariously Pushing Master
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

fastify-url-data

2.0.1 • Public • Published

fastify-url-data

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'), (err) => {
  if (err) throw err
})
 
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

MIT License

Keywords

install

npm i fastify-url-data

Downloadsweekly downloads

37

version

2.0.1

license

MIT

repository

githubgithub

last publish

collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar