Skip to content

September 16, 2022

Choose a tag to compare

@github-actions github-actions released this 16 Sep 17:28
· 3049 commits to master since this release
1965a05

@whatwg-node/server@0.4.0

Minor Changes

  • #121 a67f447 Thanks @ardatan! - Improvements;

    • createServerAdapter can now accept the request handler itself.
    createServerAdapter(req => {
      return new Response(`I got ${req.url}`);
    });

    Breaking Changes;

    • baseObject in the configuration has been removed! Now you can pass baseObject itself but baseObject needs to implement a handle method that is exactly same with handleRequest.
    - const myServerBaseObject = {...}
    + const myServerBaseObject = {
    +   handle(req) {/*...*/}
    + }
    
    - const adapter = createServerAdapter({
    -   baseObject: myServerBaseObject,
    -   handleRequest(req) {/*...*/}
    - })
    + const adapter = createServerAdapter(myServerBaseObject)
    • handleRequest has been renamed to handle which has the same signature.
    createServerAdapter({
    -   handleRequest(request) {
    +   handle(request) {
    })
    • Request in the configuration needs to be passed as a second argument.
    createServerAdapter({
    -   handleRequest(request) {
    +   handle(request) {
    -   Request: MyRequestCtor
    - })
    + }, MyRequestCtor)