| 20 | let authorizeSpy: MockInstance<FastifyInstance['authorize']>; |
| 21 | |
| 22 | async function setupServer() { |
| 23 | const fastify = Fastify(); |
| 24 | await fastify.register(cookies); |
| 25 | await fastify.register(auth); |
| 26 | authorizeSpy = vi.spyOn(fastify, 'authorize'); |
| 27 | |
| 28 | await fastify.register(redirectWithMessage); |
| 29 | await fastify.register(bouncer); |
| 30 | fastify.addHook('onRequest', fastify.authorize); |
| 31 | fastify.get('/', (_req, reply) => { |
| 32 | void reply.send({ foo: 'bar' }); |
| 33 | }); |
| 34 | return fastify; |
| 35 | } |
| 36 | |
| 37 | describe('bouncer', () => { |
| 38 | let fastify: FastifyInstance; |