Coder Social home page Coder Social logo

apigeefy's Introduction

apigeefy

========

Bundle node dependencies and use them in Apigee Edge javascript policies.

Install

npm install apigeefy

Usage

Bundle up the node module you would like to use in Apigee Edge

Create a apigeefy module

This is the file which will end up being bundled & exported to be used in apigee policy.

In the example below we use the graphql module (parse & Source) and export them. These will be bundled and exported as apigeefy modules to be used in Apigee Edge.

// graphql-parser.js
const parse = require('graphql/language/parser');
const Source = require('graphql/language/source');

exports.graphql = {parse: parse.parse, Source: Source.Source};

Bundle up with apigeefy

apigeefy <input_file_path> > <output_file_path>

ex:

apigeefy ./graphql-parser.js > graphql-bundle-min.js

Note: We can use trireme module (to check for compile errors), which runs Node.js scripts inside the JVM. Trireme is based on Rhino engine which runs on Apigee Edge.

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 GraphQL Validation</DisplayName>
  <IncludeURL>jsc://graphql-bundle-min.js</IncludeURL>
  <ResourceURL>jsc://graphql-validation.js</ResourceURL>
</Javascript>

Use it (graphql-validation.js)

...
var bundle = context.getVariable('bundle');
var graphqlRequest = context.getVariable("request.queryparam.query");
var result = bundle.apigeefy.parse(graphqlRequest);
...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.