0.0.13 • Published 7 years ago

policify v0.0.13

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

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

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

8 years ago

0.0.9

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago