Tensil
Express server Service, Controller and Routing framework.
Introduction
Tensil flexible and lightweight. It intentionally leaves out opinion and focuses on painless secure routing. The idea behind Tensil is flexibilty with just enough magic. Services and Controllers can be mounted to the root router or their own router for app segregation.
Install
$ npm install tensil -s
Usage
;; tensil.app.usebodyParser.json;tensil.app.usebodyParser.urlencoded;tensil.app.usebodyParser.text;tensil.app.usebodyParser.json; tensil .registerControllerMyController .start;
With Custom App
Using Tensil with external express() app.
;; ;tensil.app = app;
With Http Server
Using Tensil with http.createServer
;; tensil.withServer; // ORtensil.withServerexpress; // ORtensil.withServer; // OR with SSLtensil.withServer, true; //
Server
Configuring a Tensil Service.
;; ;// ORtensil.registerSerivceMyService;
Controller
Configuring a Tensil Controller.
; ;// ORtensil.registerControllerMyController, 'user';
Default Action Templates
Templates allow you to map your action decorators to a key to make the defining of generated routes for controller actions less verbose. You can always override and defined a specific path.
Simply define a template below then use as:
createreq, res
Events
A pipe "|" indicates or. By default all errors are emitted without halting by throwing an error. When options.strict
is enabled then errors will be thrown. Note when NOT prodcution strict is automatically enabled when strict is undefined. This is done to ensure there are not duplicate registrations and routes in a production environment.
Listening to all events for a given group.
tensil.on`route`,;
To listen to a specific event type you combine the event with the type separated by a colon. When listening to a specific event type the type is removed from the first argument.
tensil.on`route:mounted`,;
You can also listen to ALL events as follows:
tensil.on`*`,;
Event | Type | Value1 | Value2 |
---|---|---|---|
entity | duplicate | Error | |
policy | invalid | Error | |
filter | invalid | Error | |
route | duplicate | Error | x|
route | invalid | Error | |
entity | registered | Service | Controller | |
policy | create | IPolicy | IPolicies | |
filter | create | IFilter | IFilters } | |
route | create | IRoute | IRoutes | |
route | registered | path: string | IRouteConfig'' |
route | mounted | path: string | IRouteConfig'' |
mount | completed | null | |
init | completed | null | |
start | completed | null |
Docs
See https://blujedis.github.io/tensil/
Change
See CHANGE.md
License
See LICENSE.md