npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

okapipack

v0.3.2

Published

Helper tool for maintain Apigee proxies

Downloads

4

Readme

Okapi

Proof of concept for a tool for helping during development of Apigee Proxy bundles.

A reactive tool for handling common tasks during Apigee Proxy Bundles development.

Usage

Install it with NPM:

$ npm install okapipack

Configuration file is named okapi.json by default and its minimum setup is:

{
  "name": "apiproxy",                  // Your Proxy name. This will be used when genearting calls 
                                       // against the Apigee API
  "bundleType": "apiproxy",            // Right now the only possible value is "apiproxy"
  "sourcePath": "./src",               // Path for the source of your proxy files 
  "buildPath": "./build",              // Path hwere the generated bundle will be created
  "defaultOrg": <String>,              // Organization name used as default if none is provided
                                       // to specific commands
  "defaultEnvironment": <String>,      // Envirnment name used as default if none is provided 
                                       // to specific commands
  "server": {
    "port": 8989,                                  // Okapi server port
    "ssoEndpoint": "login.apigee.com",             // SSO Endpoint
    "apigeeEndpoint": "api.enterprise.apigee.com", // Apigee API Endpoint
    "basePath": "/v1"                              // Apigee API Basepath
  }
}

If no configuration is provided, all values will take its default values which are the ones shown in the example above.

Available commands

  • --conf <path> Path to configuration file if you don't want to use the default name and path.
  • -l --upload [-o <organization>] Build and upload the bundled proxy. It will not emit any file in the local file system.
  • -d --deploy <revision> [-o <organization> -e <environment>] Deploy the specific revision of the current proxy in the given environment in the given org.
  • -p --publish [-o <organization> -e <environment>] Uploads and deploy a new revision of the current proxy in the given environment in the given org.
  • -b --build Emits a bundle file (ZIP) for the proxy.
  • --start Start the Okapi Server.
  • --stop Stop the Okapi Server.
  • --status Return the current status of the Okapi Server.
  • --auth -u <user> -p <password> -m <MFA code> [-e] Authenticate the Okapi Server.

Folder conventions

Okapi assumes that the folder configured as the path for your source code reflects the structure of an Apigee Bundle:

src/
├── proxies/                            // Proxy Endpoints
├── targets/                            // Target Endpoints
├── policies/                           // Policies
├── resources/                          // Resource scripts or JARs
└── proxy.xml                           // The metadata file for your proxyy point

Building and uploading a proxy

One common use case is to generate a bundle and upload it immediately to your org. Often you don't need the generated file, instead you just need to upload it to your org. You can use the following command to do this:

$ okapi -l -o <your_org_name>

If you have specified a default org in your okapi.json file, the org parameter is optional and okapi will you your default org.

This command requires the Okapi Server to be running and authenticated.

Deploying a proxy

You can deploy any revision to any environment and org you have access. usually you do this after uploading a bundle to your org.

$ okapi -d -o <your_org_name> -e <environment>

If you have specified a default org and environment in your okapi.json file you don't need to specify them again in the deploy command. If you want to use a different org or environment, you can override them in the command.

This command requires the Okapi Server to be running and authenticated.

Generating a bundle

If you need to generate a ZIP file with your bundle to store it or send it, you can generate the bundle file with Okapi.

After you have created your configuration file, you can use:

$ okapi -b

Generating bundles locally doesn't require the Okapi Server.

Okapi Server

Okapi Server is nothing more than a proxy for Apigee Public API. It allows developers to use OAuth tokens with or without MFA codes without the need of providing your credentials on every call.

You can think of it as a Cookie Session keeper for curl calls.

Start the server:

$ okapi --start

Stop the server:

$ okapi --stop

Check the status the server:

$ okapi --status

Authenticate the server:

$ okapi --auth [-u <user> -p <password> -m <MFA code>] [-e]

If you don't provide any argument, okapi will ask you for your credentials. If you have MFA enabled in your account, use -m to provide your code. If you want to use environment variables for your credentials, add the parameter -e with no arguments, the values of -u and -p will be used as the names of the environment variables.

Important! Do not use Okapi Server as a public server or in production environments.

Why another Apigee bundle tool?

There are out there some mature and really good tools for handling Apigee bundles. Unfortunately, none of them allows me to use them in other libraries as a way to generate bundles in automated processes.

Also, I mainly maintain proxies that don't use NodeJS at all, but regular Apigee Edge policies. And the two main CLI tools out there are specially crafted to be used with Apigee NodeJS proxies.

I'm creating this tool looking at my personal use cases but I hope it will fit other's as well.

Dependencies

We try our best to keep Okapi at the minimum number of dependencies. At this point we use:

  • Jasmine for testing. It is a development dependency not used at runtime.
  • RxJS because almost everything in Okapy is a stream or it is converted into one.
  • jszip is used to compress files and bundle them into ZIP files as they are expected by Apigee API. It is the same library used in the Proxy Editor in the Apigee UI.
  • morral is a very small CLI helper tool with no additional dependencies.