Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.
/ jambe Public archive

Experimental NodeJS HTTP router written in C++ using N-API

License

Notifications You must be signed in to change notification settings

verdie-g/jambe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jambe

Experimental url router for NodeJS writtin in C++ using N-API.

Performance is not good because there is a huge overhead when calling native code from Javascript. A url router is not a good use case of N-API.

API

Router

constructor()
function add_route(method: string, route: string, handler: () => ()): void
function lookup(method: string, route: string): Lookup

Implementation

Instead of using a Trie, the route is tokenize using slash as a separator. This make the router slower but the code is extremely simpler.

For instance, the routes /users/:id, /users/me, /utilities, create the following tree:

               /    
      ---------|--------
      |                |
    users          utilities
    |   |
   me  :id

Possible routes conflicts like /users/me with /users/:id/posts are working using backtracking.

Usage

  • compile addon: yarn install && yarn build

About

Experimental NodeJS HTTP router written in C++ using N-API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published