0.3.0-alpha • Published 5 years ago

@peregrine/webserver v0.3.0-alpha

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

@peregrine/webserver license npm

Experimental http server for node.

Example

Check out the example that is part of this project.

To do

Before version 1.0:

  • Endpoint classes with @HttpGet, @HttpPost decorators
    class UsersEndpoint {
        @HttpGet
        getUsers(/* ... */){ /* ... */ }
    }
  • @Route(string) decorator support to endpoint classes & class methods
    @Route("/users")
    class UsersEndpoint {
        @HttpGet
        @Route("/{id}")
        getUserById(/* ... */){ /* ... */ }
    }
  • @Request, @Body, @Query(string) decorators in endpoint class methods
    @Route("/users")
    class UsersEndpoint {
        @HttpGet
        @Route("/{id}")
        getUserById(@Param("id") userId: string){ /* ... */ }
    }
  • Add custom body parsing (request + response)
    rootEndpoint.addBodyParser("application/json", jsonParser)
  • Better type checking for specific request types (HEAD without response body)
    endpoint.head(route: string, handler: (request: HttpRequest) => ResponseWithoutBody)
  • Add new authentication handling and @AuthenticationHandler (v1.0+) & @Auth decorators for endpoint classes

    class ProfileEndpoint {
        @HttpPut
        @Route("/{profileId}")
        updateProfile(@Auth authenticatedUser: User){ /* ... */ }
    
        @AuthenticationHandler
        onVerifyAuthentication(request: HttpRequest) {
            const user = getUserFromTokenOrNull(request.headers.get("X-Token"))
            if(user === null) {
                throw new AuthenticationInvalidError()
            }
        }
    }
  • Add custom error throwing and handling and add @ErrorHandler (v1.0+) decorator for endpoint classes

    rootEndpoint.post("/", () => throw new MethodNotAllowedError())
    rootEndpoint.onError((error: Error): HttpResponse => { /* ... */ })
  • Improve tests
    • Add more unit tests
    • Add integration tests

After version 1.0:

  • Resolve @todo statement at ./lib/main/Async.ts#L22
  • Add more response types to the ResponseBuilder class
  • Add a folder to serve statically
  • Make sure /index.html is called when the path is /
  • Automatically add methods (like HEAD when GET is registered), allow custom override.
  • Automatically add headers to response (like Date), allow custom override.
  • Add common HTTP Headers to HttpRequest/ResponseBuilder
    httpRequest.getLanguagesArray()
    responseBuilder.addDate(/* ... */)
    responseBuilder.setCachePolicy(/* ... */)
  • @RequestMiddleware, @ResponseMiddleware decorators in endpoint class methods
    @Route("/users")
    class UsersEndpoint {
        @ResponseMiddleware
        onResponse(/* ... */) { /* ... */ }
    }
0.5.13

5 years ago

0.5.12

6 years ago

0.5.11

6 years ago

0.5.10

6 years ago

0.5.7

6 years ago

0.5.9

6 years ago

0.5.6

6 years ago

0.5.4

6 years ago

0.5.5

6 years ago

0.5.3

6 years ago

0.5.2

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.3.0-alpha

6 years ago

0.2.7

7 years ago

0.2.6

7 years ago

0.2.5

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago