Nanoscale Parts Manufacturing

    trailpack-policy

    1.0.2 • Public • Published

    trailpack-policy

    Gitter NPM version Build status Dependency Status Code Climate Follow @trailsjs on Twitter

    Trailpack policy class. Exposes Trails Application resources to the class instances.

    Trailpack policies should extend this class, it allow you to use hapi API interface for all webserver compatible (currently trailpack-hapi and trailpack-express).

    For basic Trails policies you should use trails-policy.

    Usage

    In api/policies/MyPolicy.js:

    const Policy = require('trailpack-policy')
     
    class MyPolicy extends Policy {
      policyMethod (request, response) {
        // ...
      }
    }

    In config/policies.js:

    module.exports = {
      SomeController: {
        doSomething: ['MyPolicy.policyMethod']
      }
    }

    Note: Even if you are only applying one policy to a controller method, you should still enclose the string 'MyPolicy.policyMethod' in an array.

    Install

    License

    MIT

    Install

    npm i trailpack-policy

    DownloadsWeekly Downloads

    3

    Version

    1.0.2

    License

    MIT

    Last publish

    Collaborators

    • kos