Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hof-behaviour-hooks

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hof-behaviour-hooks

HOF Behaviour for running lifecycle hooks

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

#hof-behaviour-hooks

HOF Behaviour enabling lifecycle hooks for extending functionality in main form pipeline.

##Usage

###With mixwith.js

const mix = require('mixwith').mix;
const Hooks = require('hof-behaviour-hooks');
const BaseController = require('hof-form-controller');

class MyController extends mix(BaseController).with(Hooks) {
  ...
}

MyController now extends hof-form-controller and has hof-behaviour-hooks functionality mixed in.

##Functionality

The following hooks are currently supported, the methods are GET/POST pipeline methods from hof-form-controller:

####GET

  • _getErrors - 'pre-getErrors', 'post-getErrors'
  • _getValues - 'pre-getValues', 'post-getValues'
  • _locals - 'pre-locals', 'post-locals'
  • render - 'pre-render', 'post-render'

####POST

  • _process - 'pre-process', 'post-process'
  • _validate - 'pre-validate', 'post-validate'
  • saveValues - 'pre-saveValues', 'post-saveValues'
  • successHandler - 'pre-successHandler', 'post-successHandler'

###In field config

fields.js

module.exports = {
  'field-1': {
    hooks: {
      'post-locals': (req, res, next) => {
        Object.assign(res.locals, {
          foo: 'bar'
        });
        next();
      },
      'pre-process': (req, res, next) => {
        req.body['field-1'] = req.body['field-1'].toUpperCase();
        next();
      }
    }
  }
}

FAQs

Package last updated on 27 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc