fastify/fastify-caching

TypeError: fastify.register error in sample usage in docs

nimasrn opened this issue ยท 1 comments

๐Ÿ› Bug Report

the sample usage has some error in using and import Fastify
When I use the example code and run the node server I get the error TypeError: fastify.register is not a function

To Reproduce

const http = require('http')
const fastify = require('fastify')
const fastifyCaching = require('fastify-caching')

fastify.register(
  fastifyCaching,
  {privacy: fastifyCaching.privacy.NOCACHE},
  (err) => { if (err) throw err }
)

fastify.get('/', (req, reply) => {
  reply.send({hello: 'world'})
})

fastify.listen(3000, (err) => {
  if (err) throw err

  http.get('http://127.0.0.1:3000/', (res) => {
    console.log(res.headers['cache-control'])
  })
})

Expected behavior

not getting the TypeError and server runs successfully

Your Environment

  • node version: 14
  • fastify version: >=3.0.0
  • os: Linux

#47 I fixed the issue and I have already requested to be merged