@aegenet/belt-fastify-abort
v2.3.0
Published
Auto add an AbortController on all Fastify Request
Downloads
616
Readme
@aegenet/belt-fastify-abort
Auto add an AbortController on all Fastify Request
Node only!
💾 Installation
yarn add @aegenet/belt-fastify-abort@^2.0.0
# or
npm i @aegenet/belt-fastify-abort@^2.0.0
📝 Usage
Node.js
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({});
});