Skip to content

How to add options or middleware calls per route? Does this work with hooks? #35

Description

E.g. need to pass options for an auth-Route with rate limit (https://github.com/fastify/fastify-rate-limit)
Need to add addtional middlewares to a specific route.
I did not find anything in the docs or src/tests about that.

Example from fastify-rate-limit

fastify.get('/public/sub-rated-1', {
  config: {
    rateLimit: {
      timeWindow: '1 minute',
      allowList: ['127.0.0.1'],
      onExceeding: function (request, key) {
        console.log('callback on exceededing ... executed before response to client')
      },
      onExceeded: function (request, key) {
        console.log('callback on exceeded ... to black ip in security group for example, request is give as argument')
      }
    }
  }
}, (request, reply) => {
  reply.send({ hello: 'from sub-rated-1 ... using default max value ... ' })
})

How can this be done with a fastify.zod.post?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions