GithubHelp home page GithubHelp logo

tyayers / apigee-templater-custom Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 64 KB

Sample project on how to create a customized apigee-templater CLI.

License: Apache License 2.0

JavaScript 14.63% TypeScript 85.37%

apigee-templater-custom's Introduction

apigee-templater-custom

This project is a template to show how to create a customized version of apigee-templater. This template has a custom API key validation plugin in ./lib/auth.apikey.plugin.ts, which is replaces the default API key validation plugin in apigee-templater.

Getting started

To get started, clone this repository and install dependencies.

# Clone this repository
git clone https://github.com/apigee/apigee-templater-custom.git
cd apigee-templater-custom
npm install

Then run the unit tests to see how the customized version of apigee-templater is used with a custom plugin for API key validation.

# Run the unit tests
npm run build
npm run test

You should have a subdirectory under ./test/proxies with a generated proxy, included the extracted proxy bundle. As you can see in ./test/data/input1.json, the input was a simple configuration for a proxy to https://httpbin.org with custom API key validation.

The unit tests in ./test/data/convert.text.ts verify that the generated proxy file exists, and that the expected files and contents are included in the generated proxy bundle.

Customizing

The file ./bin/mytemplater.js shows you how you can create your own CLI tool with your own customized plugins. This example has a customized API key validation plugin in ./lib/auth.apikey.plugin.ts.

Testing

You can easily test your CLI by just running the mytemplater.js class using node.

# Run the CLI
npm run build
cd ./bin
node mytemplater.js

You should get the default functionality of apigee-templater, but with your custom plugins applied.

$ node mytemplater.js
> Welcome to Apigee Templater, use -h for more command line options. 
? What should the proxy be called? MyProxy
? Which base path should be used? /test
? Which backend target URL should be called? https://httpbin.org
? Do you want to deploy the proxy to an Apigee X environment? No
> Proxy MyProxy generated to ./MyProxy.zip in 129 milliseconds.

You can also test your CLI locally on your system by just linking the module, and then using the command

# Go to the project root
npm link

# Then anywhere on your system you can use the CLI
mytemplater -h

## If you want to remove it, unlink the global package
npm uninstall --global mytemplater

Publishing

To publish your CLI, simply change the name and details in package.json and run npm publish.

apigee-templater-custom's People

Contributors

tyayers avatar

Watchers

 avatar

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.