donesies
v1.0.1
Published
Add AbortSignal integration into Hapi
Readme
donesies
Add AbortSignal integration into Hapi.js.
Lead Maintainer: Gil Pedersen
Setup and configuration
const Donesies = require('donesies');
await server.register(Donesies);
server.route({
method: 'get',
path: '/path',
handler(request, h) {
const res = await fetch(aRemoteUrl, { signal: request.signal });
return res.json();
}
});The plugin adds a .signal property to the request object, which will trigger with an AbortError when
the client request is closed. Either because the response was fully transmitted, or since it was prematurely
closed by the remote end, from a connection error, or from internal processing or timeout.
Known issues
When using with server.inject(), the @hapi/shot module needs to be version 6.0.3 or newer.
