GitXplorerGitXplorer
o

policify

public
5 stars
3 forks
2 issues

Commits

List of commits on branch master.
Unverified
d5b4971616a31f98d7aebd9e1fdbcac52644827b

update readme

oorangewise committed 8 years ago
Unverified
7c152eceb756e90efd2469000fed21cadf281aa8

0.0.10

oorangewise committed 8 years ago
Unverified
d4b147b57058e7f64b694af9d45c3357c0fc11f3

add keywords

oorangewise committed 8 years ago
Unverified
8d83ae1da3d86dbd43dd53de756b2d0012a36d36

0.0.9

oorangewise committed 8 years ago
Unverified
baca460fc98d49ef6a1d6520d9e35a9c2b75f8f5

linting

oorangewise committed 8 years ago
Unverified
c79481855036b2ca07c6e51f4db55e3cf48a4c59

0.0.8

oorangewise committed 8 years ago

README

The README file for this repository.

policify

npm version Build Status JavaScript Style Guide

Bundle node dependencies and use them in Apigee Edge javascript policies. Built upon the excellent Browserify project.

Install

npm install policify

Usage

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 = policify

Bundle it up with policify

npm install policify uglify-js
policify ./validate-schema.js | uglifyjs > bundle.js

Add 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)
...