Skip to content

typeclasses/router-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

router

A typical web server looks like a function of type

(request: Request) => Promise<Response>

for some types Request and Response.

This is a minimal tool for defining and combining such functions.

See readme.test.ts for an example application.

Request

The Request type can be any record, but this library assumes a few special attributes:

  • method: string - The HTTP request method.

  • path: string | null - A relative URL pathname constructed from the request path, (e.g. as new URL(request.url).pathname.slice(1) to remove the leading slash but perhaps modified by intermediate processing before reaching the server).

  • parent: string - When descending into a dynamicDirectory, the segment that was popped off the front of the URL path.

Response

The Response type can be anything.

About

Minimal typescript http server routing library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors