Forbin.js
ES6 Component for controllers with filter support.
; const logRequest = Symbol authenticate = Symbol logResponse = Symbol; { this; this; this; this; } { //log request before every action on the controller ; } { //log response after some action ; } { //authenticate user ; } { //here the request is logged and the client authenticated //do your action and send the response } { //here the client is authenticated but the log skipped //do your action and send the response //after this action the response will be logged } { //here the request is logged but is a public operation //do your action and send the response }
Quality and Compatibility
Every single build and release is automatically tested on the following platforms:
If your platform is not listed above, you can test your local environment for compatibility by copying and pasting the following commands into your terminal:
npm install forbin
cd node_modules/forbin
gulp test-local
Installation
Copy and paste the following command into your terminal to install Forbin:
npm install forbin --save
Import / Require
// ES6
import Controller from "forbin";
// ES5
var Controller = require("forbin");
// Require.js
define(["require"] , function (require) {
var Controller = require("forbin");
});
Getting Started
Using it
You should extend the base Controller provided within forbin in order to apply filters and take advantage of the provided functionality.
As the above example shows, you can define a specific filter to every action on the controller, to a specific one, or to an array of actions.
There are three filter functions available right now:
- before
- after
- skip
All those functions share the same interface:
; //this will apply a before filter to all actions; //this will apply a before filter to a specific action; //this will apply the filter to the provided array of actions ; //this will apply an after filter to all actions; //this will apply an after filter to a specific action; //this will apply the filter to the provided array of actions ; //this will skip a filter on all actions; //this will skip a filter on a specific action; //this will skip the filter on the provided array of actions
How to Contribute
See something that could use improvement? Have a great feature idea? We listen!
You can submit your ideas through our issues system, or make the modifications yourself and submit them to us in the form of a GitHub pull request.
We always aim to be friendly and helpful.
Running Tests
It's easy to run the test suite locally, and highly recommended if you're using Forbin.js on a platform we aren't automatically testing for.
npm test