Auto add an AbortController on all Fastify Request
Node only!
yarn add @aegenet/belt-fastify-abort@^2.0.0
# or
npm i @aegenet/belt-fastify-abort@^2.0.0
import { fastifyAbortRegister, type FastifyRequestAbortCtrl } from '@aegenet/belt-fastify-abort';
import fastify from 'fastify';
const app = fastify();
// register the fastify abort
fastifyAbortRegister(app);
fastify.post('/api/random', async (request: FastifyRequestAbortCtrl, reply) => {
// AbortController is available in abortCtrl
assert.ok(request.abortCtrl);
/** your code */
reply.code(200).send({});
});