How to use middlewarify - 10 common examples

To help you get started, we’ve selected a few middlewarify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thanpolas / crude / lib / crude.js View on Github external
*       @param {Function(Object)} update
   *       @param {Function(Object)} count
   */
  this.controller = controller;

  // define CRUD middleware
  this.create = [];
  this.readOne = [];
  this.readList = [];
  this.update = [];
  this.delete = [];

  // define CRUD Query middleware
  function noopReturn(query) {return query;}
  middlewarify.make(this, 'createQuery', noopReturn);
  middlewarify.make(this, 'readOneQuery', noopReturn);
  middlewarify.make(this, 'readListQuery', noopReturn);
  middlewarify.make(this, 'updateQuery', noopReturn);
  middlewarify.make(this, 'deleteQuery', noopReturn);

  var self = this;
  function use(middleware) {
    this.push(middleware);
    return self;
  }
  this.create.use = use;
  this.readOne.use = use;
  this.readList.use = use;
  this.update.use = use;
  this.delete.use = use;

  this._setDefaults();
github thanpolas / crude / lib / crude.js View on Github external
*/
  this.controller = controller;

  // define CRUD middleware
  this.create = [];
  this.readOne = [];
  this.readList = [];
  this.update = [];
  this.delete = [];

  // define CRUD Query middleware
  function noopReturn(query) {return query;}
  middlewarify.make(this, 'createQuery', noopReturn);
  middlewarify.make(this, 'readOneQuery', noopReturn);
  middlewarify.make(this, 'readListQuery', noopReturn);
  middlewarify.make(this, 'updateQuery', noopReturn);
  middlewarify.make(this, 'deleteQuery', noopReturn);

  var self = this;
  function use(middleware) {
    this.push(middleware);
    return self;
  }
  this.create.use = use;
  this.readOne.use = use;
  this.readList.use = use;
  this.update.use = use;
  this.delete.use = use;

  this._setDefaults();

  if (this.express) {
github thanpolas / crude / entity.js View on Github external
var Entity = module.exports = function(Model, optUdo) {
  EventEmitter.call(this);

  /** @type {mongoose.Model} The mongoose model */
  this.Model = Model;

  /** @type {?Object} The current user or null for anonymous */
  this.udo = optUdo || null;

  // Create primitive middlewares
  midd.make(this, 'create', this._create.bind(this));
  midd.make(this, 'read', this._read.bind(this));
  midd.make(this, 'readOne', this._readOne.bind(this));
  midd.make(this, 'readLimit', this._readLimit.bind(this));
  midd.make(this, 'update', this._update.bind(this));
  midd.make(this, 'delete', this._delete.bind(this));
  midd.make(this, 'count', this._count.bind(this));
};
util.inherits(Entity, EventEmitter);
github thanpolas / crude / lib / crude.js View on Github external
this.controller = controller;

  // define CRUD middleware
  this.create = [];
  this.readOne = [];
  this.readList = [];
  this.update = [];
  this.delete = [];

  // define CRUD Query middleware
  function noopReturn(query) {return query;}
  middlewarify.make(this, 'createQuery', noopReturn);
  middlewarify.make(this, 'readOneQuery', noopReturn);
  middlewarify.make(this, 'readListQuery', noopReturn);
  middlewarify.make(this, 'updateQuery', noopReturn);
  middlewarify.make(this, 'deleteQuery', noopReturn);

  var self = this;
  function use(middleware) {
    this.push(middleware);
    return self;
  }
  this.create.use = use;
  this.readOne.use = use;
  this.readList.use = use;
  this.update.use = use;
  this.delete.use = use;

  this._setDefaults();

  if (this.express) {
    this.addRoutes(this.express);
github thanpolas / crude / lib / crude.js View on Github external
*       @param {Function(Object)} count
   */
  this.controller = controller;

  // define CRUD middleware
  this.create = [];
  this.readOne = [];
  this.readList = [];
  this.update = [];
  this.delete = [];

  // define CRUD Query middleware
  function noopReturn(query) {return query;}
  middlewarify.make(this, 'createQuery', noopReturn);
  middlewarify.make(this, 'readOneQuery', noopReturn);
  middlewarify.make(this, 'readListQuery', noopReturn);
  middlewarify.make(this, 'updateQuery', noopReturn);
  middlewarify.make(this, 'deleteQuery', noopReturn);

  var self = this;
  function use(middleware) {
    this.push(middleware);
    return self;
  }
  this.create.use = use;
  this.readOne.use = use;
  this.readList.use = use;
  this.update.use = use;
  this.delete.use = use;

  this._setDefaults();
github thanpolas / crude / entity.js View on Github external
var Entity = module.exports = function(Model, optUdo) {
  EventEmitter.call(this);

  /** @type {mongoose.Model} The mongoose model */
  this.Model = Model;

  /** @type {?Object} The current user or null for anonymous */
  this.udo = optUdo || null;

  // Create primitive middlewares
  midd.make(this, 'create', this._create.bind(this));
  midd.make(this, 'read', this._read.bind(this));
  midd.make(this, 'readOne', this._readOne.bind(this));
  midd.make(this, 'readLimit', this._readLimit.bind(this));
  midd.make(this, 'update', this._update.bind(this));
  midd.make(this, 'delete', this._delete.bind(this));
  midd.make(this, 'count', this._count.bind(this));
};
util.inherits(Entity, EventEmitter);
github thanpolas / crude / entity.js View on Github external
var Entity = module.exports = function(Model, optUdo) {
  EventEmitter.call(this);

  /** @type {mongoose.Model} The mongoose model */
  this.Model = Model;

  /** @type {?Object} The current user or null for anonymous */
  this.udo = optUdo || null;

  // Create primitive middlewares
  midd.make(this, 'create', this._create.bind(this));
  midd.make(this, 'read', this._read.bind(this));
  midd.make(this, 'readOne', this._readOne.bind(this));
  midd.make(this, 'readLimit', this._readLimit.bind(this));
  midd.make(this, 'update', this._update.bind(this));
  midd.make(this, 'delete', this._delete.bind(this));
  midd.make(this, 'count', this._count.bind(this));
};
util.inherits(Entity, EventEmitter);
github thanpolas / crude / lib / crude.js View on Github external
*       @param {Function(Object)} readOne
   *       @param {Function(Object)} update
   *       @param {Function(Object)} count
   */
  this.controller = controller;

  // define CRUD middleware
  this.create = [];
  this.readOne = [];
  this.readList = [];
  this.update = [];
  this.delete = [];

  // define CRUD Query middleware
  function noopReturn(query) {return query;}
  middlewarify.make(this, 'createQuery', noopReturn);
  middlewarify.make(this, 'readOneQuery', noopReturn);
  middlewarify.make(this, 'readListQuery', noopReturn);
  middlewarify.make(this, 'updateQuery', noopReturn);
  middlewarify.make(this, 'deleteQuery', noopReturn);

  var self = this;
  function use(middleware) {
    this.push(middleware);
    return self;
  }
  this.create.use = use;
  this.readOne.use = use;
  this.readList.use = use;
  this.update.use = use;
  this.delete.use = use;
github thanpolas / crude / entity.js View on Github external
var Entity = module.exports = function(Model, optUdo) {
  EventEmitter.call(this);

  /** @type {mongoose.Model} The mongoose model */
  this.Model = Model;

  /** @type {?Object} The current user or null for anonymous */
  this.udo = optUdo || null;

  // Create primitive middlewares
  midd.make(this, 'create', this._create.bind(this));
  midd.make(this, 'read', this._read.bind(this));
  midd.make(this, 'readOne', this._readOne.bind(this));
  midd.make(this, 'readLimit', this._readLimit.bind(this));
  midd.make(this, 'update', this._update.bind(this));
  midd.make(this, 'delete', this._delete.bind(this));
  midd.make(this, 'count', this._count.bind(this));
};
util.inherits(Entity, EventEmitter);
github thanpolas / crude / entity.js View on Github external
var Entity = module.exports = function(Model, optUdo) {
  EventEmitter.call(this);

  /** @type {mongoose.Model} The mongoose model */
  this.Model = Model;

  /** @type {?Object} The current user or null for anonymous */
  this.udo = optUdo || null;

  // Create primitive middlewares
  midd.make(this, 'create', this._create.bind(this));
  midd.make(this, 'read', this._read.bind(this));
  midd.make(this, 'readOne', this._readOne.bind(this));
  midd.make(this, 'readLimit', this._readLimit.bind(this));
  midd.make(this, 'update', this._update.bind(this));
  midd.make(this, 'delete', this._delete.bind(this));
  midd.make(this, 'count', this._count.bind(this));
};
util.inherits(Entity, EventEmitter);

middlewarify

Apply the middleware pattern to any function.

ISC
Latest version published 3 years ago

Package Health Score

42 / 100
Full package analysis

Popular middlewarify functions