1.0.0 • Published 4 years ago

radrou v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

RadRou

Fast as f**k radix tree router ported and adapted from httprouter (which is written in go). I modified this so it can take an arbitrary value instead of a handler function, so it can be more generic and more easiley adapted to other use cases.

Installation

npm i radrou
yarn add radrou

Usage

import { Node } from 'radrou';

interface Value {
  handler: (req: IncomingMessage, res: ServerResponse): Promise<void>
  validate: { ... }
}

const tree = new Node<Value>()

tree.add('/posts/:id', {
  handler: (req,res) => {
    // your logic or whatever value
  },
  validate: { ... }
})

tree.find('/posts/123') // => { value: { handler, validate }, params: [{ key: 'id', value: '123 }] }
1.0.1

4 years ago

1.0.0

4 years ago