policify
Version:
Bundle node dependencies and use them in Apigee Edge javascript policies
77 lines (55 loc) • 1.85 kB
Markdown
policify
========
[![npm version][npm-badge]][npm-url]
[![Build Status][travis-badge]][travis-url]
[](http://standardjs.com/)
Bundle node dependencies and use them in Apigee Edge javascript policies. Built upon the excellent Browserify project.
```
npm install policify
```
In the example below we use the z-schema module in a new module 'policify'. The policify modules will be used in Apigee.
```javascript
// 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 = policify
```
```
npm install policify uglify-js
policify ./validate-schema.js | uglifyjs > bundle.js
```
```
<?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>
```
```
...
var bundle = context.getVariable('bundle')
bundle.policify.validateSchema(target, schema)
...
```
[]: https://badge.fury.io/js/policify.svg
[]: https://badge.fury.io/js/policify
[]: https://travis-ci.org/orangewise/policify.svg?branch=master
[]: https://travis-ci.org/orangewise/policify