0.0.0-alpha.1 • Published 6 years ago
@restify-ts/router v0.0.0-alpha.1
@restify-ts/router
This is a fork of koa-tree-router.
Install
npm i ts-di @restify-ts/router
# OR
yarn add ts-di @restify-ts/router
Where ts-di is a dependencie.
Usage
import { Router, Tree } from '@restify-ts/router';
import { ReflectiveInjector } from 'ts-di'; // This is a dependencie
const injector = ReflectiveInjector.resolveAndCreate([Tree, MyRouter]);
const router = injector.get(Router) as Router;
router.on('GET', '/', () => { /* Here some handler */ });
const { handle, params } = router.find('GET', '/');
Benchmarks
git clone git@github.com:restify-ts/router.git restify-ts-router
cd restify-ts-router
npm i
npm run compile
npm run bench
Results on 04.05.2019:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Running in random order
============================================================
Lib | Bench, ops/sec | Memory usage, KB
============================================================
@restify-ts/router | 2,475,722 | 9,017
------------------------------------------------------------
koa-tree-router | 2,383,507 | 6,118
------------------------------------------------------------
trek-router | 1,826,437 | 5,453
------------------------------------------------------------
find-my-way | 1,424,243 | 7,840
------------------------------------------------------------
0.0.0-alpha.1
6 years ago