trails-policy
v2.0.0
Published
Trails Policy Class
Downloads
315
Readme
trails-policy
Note: This module is deprecated in Trails v2. It will be merged into trailsjs/trails in v3.
Trails Policy Class. Exposes Trails Application resources to the class instances. Policies should extend this Class.
Usage
In api/policies/MyPolicy.js:
const Policy = require('trails-policy')
class MyPolicy extends Policy {
policyMethod () {
// ...
}
}
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.