@fastify/url-data
TypeScript icon, indicating that this package has built-in type declarations

5.4.0 • Public • Published

@fastify/url-data

CI NPM version 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

Dependencies (2)

Dev Dependencies (9)

Package Sidebar

Install

npm i @fastify/url-data

Weekly Downloads

25,414

Version

5.4.0

License

MIT

Unpacked Size

14.4 kB

Total Files

14

Last publish

Collaborators

  • gurgunday
  • metcoder95
  • galvez
  • simenb
  • coopflow
  • simoneb
  • rafaelgss
  • starptech
  • delvedor
  • matteo.collina
  • allevo
  • jsumners
  • zekth
  • eomm
  • fox1t
  • airhorns
  • kibertoad
  • climba03003
  • is2ei
  • fdawgs