This is the changelog for node-fetch-server. It follows semantic versioning.
- Handle backpressure correctly in response streaming
- Add
/srcto npm package, so "go to definition" goes to the actual source - Use one set of types for all built files, instead of separate types for ESM and CJS
- Build using esbuild directly instead of tsup
- Update typings and docs for http2 support
- Add http/2 support
import * as http2 from 'node:http2';
import { createRequestListener } from '@mjackson/node-fetch-server';
let server = http2.createSecureServer(options);
server.on(
'request',
createRequestListener((request) => {
let url = new URL(request.url);
if (url.pathname === '/') {
return new Response('Hello HTTP/2!', {
headers: {
'Content-Type': 'text/plain',
},
});
}
return new Response('Not Found', { status: 404 });
}),
);- Iterate manually over response bodies in
sendResponseinstead of usingfor await...of. This seems to avoid an issue where the iterator tries to read from a stream after the lock has been released.
- Expose
createHeaders(req: http.IncomingMessage): HeadersAPI for creating headers from the headers of incoming request objects. - Update
sendResponseto use an object to add support for libraries such as express while maintainingnode:httpandnode:httpscompatibility.
- Fix low-level API example in the README
- BREAKING: Change
createRequestsignature tocreateRequest(req, res, options)so the abort signal fires on theres's "end" event instead ofreq
- Added
createRequest(req: http.IncomingMessage, options): RequestandsendResponse(res: http.ServerResponse, response: Response): Promise<void>exports to assist with building custom fetch servers
- Small perf improvement from avoiding accessing
req.headersand readingreq.rawHeadersinstead - Added CommonJS build
- Initial release