baucis-decorators

1.0.3 • Public • Published

baucis-decorators

Some helper methods for decorating baucis controllers. Controllers can inherit decorators from other controllers.

Usage

Use npm install baucis-decorators --save along with any decorators you'd like to use. See this query for Loggur's current list.

Quick Example

controllers/User.js

var baucis = require('baucis');
var decorators = require('baucis-decorators');
var doSomething = require('baucis-decorator-do-something');
 
// `UserController` will inherit `ResourceController`'s decorators
var ResourceController = require('../controllers/Resource.js');
 
// ensure model is initialized
var UserModel = require('../models/User.js');
 
// create REST endpoint using `baucis`
var UserController = baucis.rest('User');
 
// decorate controller
decorators.add.call(UserController, [
  doSomething,
  ResourceController
]);
 
/** Alternatively use a string and omit the above `require` statement:
decorators.add.call(UserController, [
  'baucis-decorator-do-something',
  ResourceController
]);
 **/
 
/**
 * Expose controller.
 */
module.exports = UserController;

Detailed Example

See baucis-decorators-example. Use as many decorators as you want. A handful of decorators depend on other decorators.

Decorators List

For now, see this query. Submit a pull request if you'd like to add decorators of your own to this README.

Package Sidebar

Install

npm i baucis-decorators

Weekly Downloads

2

Version

1.0.3

License

MIT

Last publish

Collaborators

  • timbur