September 16, 2022
·
3049 commits
to master
since this release
@whatwg-node/server@0.4.0
Minor Changes
-
#121
a67f447Thanks @ardatan! - Improvements;createServerAdaptercan now accept the request handler itself.
createServerAdapter(req => { return new Response(`I got ${req.url}`); });
Breaking Changes;
baseObjectin the configuration has been removed! Now you can passbaseObjectitself butbaseObjectneeds to implement ahandlemethod that is exactly same withhandleRequest.
- const myServerBaseObject = {...} + const myServerBaseObject = { + handle(req) {/*...*/} + } - const adapter = createServerAdapter({ - baseObject: myServerBaseObject, - handleRequest(req) {/*...*/} - }) + const adapter = createServerAdapter(myServerBaseObject)
handleRequesthas been renamed tohandlewhich has the same signature.
createServerAdapter({ - handleRequest(request) { + handle(request) { })Requestin the configuration needs to be passed as a second argument.
createServerAdapter({ - handleRequest(request) { + handle(request) { - Request: MyRequestCtor - }) + }, MyRequestCtor)