Skip to content

Latest commit

 

History

History
37 lines (26 loc) · 836 Bytes

README.md

File metadata and controls

37 lines (26 loc) · 836 Bytes

npm version

@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({});
});