You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And then we can use it now too for IncomingMessage:
constreq=newIncomingMessage(/* ... */);// no changes in usageconstaccept=accepts(req);
And also we can use it easy with Request instance or any other request value:
constreq=newRequest(/* ... */);// easy making wrapper object for use with Requestconstaccept=accepts({getHeader: headerName=>req.headers.get(headerName)});
Idea 3
Maybe we can make just TypeScript types of this library more abstract, for example:
The text was updated successfully, but these errors were encountered:
krutoo
changed the title
Can we reduce type of req from IncomingMessage to just {headers: Headers}?
Can we make this library more abstract?
Mar 20, 2024
Hi, i want to use this library with not only
IncomingMessage
instances.Node.js 16+ has Fetch API now and it has global constructors such as
Request
,Response
,Headers
and other.Also i see that implementation of this library uses only
headers
field fromreq
parameter.Idea 1
Maybe we can make this library more abstract, for example we can make next interface changes:
With this interface we can use this library with instance of any class:
Idea 2
Incoming message already has
getHeader
method, we can make interface like:And then we can use it now too for
IncomingMessage
:And also we can use it easy with
Request
instance or any other request value:Idea 3
Maybe we can make just TypeScript types of this library more abstract, for example:
The text was updated successfully, but these errors were encountered: