Miss any of our Open RFC calls?Watch the recordings here! »

fastify-request-language

2.0.0 • Public • Published

fastify-request-language

Build Status XO code style

Adds language to the Fastify request object by parsing Accept-Language HTTP Header.

Requirements

  • Node >= 12
  • fastify >= 3

Install

npm install fastify-request-language

Usage

const fastify = require('fastify')({
    logger: true,
    trustProxy: true,
});
 
fastify.register(require('fastify-request-language'), {
    languages: ['en', 'hi'],
});
 
// Access language in request.language
fastify.get('/', (request, reply) => {
    reply.send({ language: request.language });
});
 

Install

npm i fastify-request-language

DownloadsWeekly Downloads

106

Version

2.0.0

License

MIT

Unpacked Size

5.62 kB

Total Files

7

Last publish

Collaborators

  • avatar
  • avatar