It is a super-performance routing middleware based on find-my-way, which can be directly connected to the current mainstream server framework and provides programmable AOP annotation programming.
For the latest stable version:
$ npm install @typeservice/radix
import Koa from '@typeservice/koa';
import Http from '@typeservice/radix';
const app = new Koa(8000);
const http = new Http();
http.scan('service', __dirname);
http.container.bind('a').toConstantValue(99);
app.use(http.compose());
app.httpBootstrap();
app.listen();
It is created based on https://www.npmjs.com/package/find-my-way, so you can use all the parameters above it.
- Trailing slashes can be ignored by supplying the
ignoreTrailingSlash
option - You can set a custom length for parameters in parametric (standard, regex and multi) routes by using
maxParamLength
option, the default value is 100 characters. - If you are using a regex based route, it will throw an error if detects potentially catastrophic exponential-time regular expressions (internally uses safe-regex2).If you want to disable this behavior, pass the option
allowUnsafeRegex
. - According to RFC3986, it is case sensitive by default. You can disable this by setting the
caseSensitive
option to false: in that case, all paths will be matched as lowercase, but the route parameters or wildcards will maintain their original letter casing.
.scan(dir, cwd)
It automatically scans files under the folder for automatic injection into internal routes and dependencies. You don't have to worry about it.
cwd
is optional
http.scan('service', __dirname);
.compose()
Generate a service middleware.
http.compose()
Copyright (c) 2019-present, yunjie (Evio) shen