0.0.13 • Published 8 years ago
policify v0.0.13
policify
Bundle node dependencies and use them in Apigee Edge javascript policies. Built upon the excellent Browserify project.
Install
npm install policifyUsage
Bundle up the node module you would like to use in Apigee Edge
Create a policify module
In the example below we use the z-schema module in a new module 'policify'. The policify modules will be used in Apigee.
// validate-schema.js
var ZSchema = require('z-schema')
ZSchema = new ZSchema({
breakOnFirstError: true,
noExtraKeywords: true,
ignoreUnknownFormats: false,
reportPathAsArray: true
})
var policify = {
validateSchema: function (injected, schema) {
return ZSchema.validate(injected, schema)
}
}
module.exports = policifyBundle it up with policify
npm install policify uglify-js
policify ./validate-schema.js | uglifyjs > bundle.jsAdd it to Apigee using a JS policy
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Javascript timeLimit="200" async="false" continueOnError="true" enabled="true" name="Add Output Validation">
<DisplayName>Add Output Validation</DisplayName>
<IncludeURL>jsc://bundle.js</IncludeURL>
<ResourceURL>jsc://schema-validation.js</ResourceURL>
</Javascript>Use it (schema-validation.js)
...
var bundle = context.getVariable('bundle')
bundle.policify.validateSchema(target, schema)
...