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

api-deploy

v0.3.14

Published

API Deploy publishes your Amazon Lambda functions and exports a JS SDK to use on the Web. Your SDK and Lambdas are both built based on the `config.json` that you supply.

Downloads

157

Readme

API Deploy

API Deploy is a Command Line Tool to publish your API. Currently, AWS Lambda is implemented, with API Gateway on the way. You can also export an SDK to use on the Web or Node (more platforms to come). Your SDK and Lambdas are both built based your project's deployfile.js.

To use API Deploy:

First, you'll need to npm install api-deploy -g. This gives you a new terminal command: api. Now, create a deployfile.js in your project:

var deployer = require('api-deploy').configure({
    sdk: {
        name: 'MyAPI',
        url: 'http://myapi.com'
    },
    swagger: {
        path: './swagger.json'
    },
    routes: require('./routes')
});

var pluginConfig = {
        lambda: {
            role: 'arn:aws:iam::xxxxxxxxxx:role/root'
        },
        aws: {
            profile: config.aws.profile,
            region: 'us-east-1',
            IdentityPoolId: 'xxxxx'
        }
    };

require('api-deploy/plugins/local').register(deployer).configure(pluginConfig);
require('api-deploy/plugins/lambda').register(deployer).configure(pluginConfig);
require('api-deploy/plugins/apigateway').register(deployer).configure(pluginConfig);

module.exports = deployer;

Now, you can deploy your API at API Gateway:

  • api deploy apigateway - Deploy your API Gateway to AWS
  • api deploy apigateway /accounts /other {operationId} - Deploy selected API Gateway routes (also deploys child/ancestor routes)
  • api deploy apigateway --sdk - Deploy your API Gateway and generate a connected SDK

Now, you can deploy your Lambdas with:

  • api deploy lambda - Deploy your Lambdas to AWS
  • api deploy lambda /accounts /other {operationId} - Deploy selected Lambdas (also deploys child/ancestor routes)
  • api deploy lambda --sdk - Deploy your Lambdas and generate a connected SDK

How can I test my code locally?

API Deploy comes with a local hapi server that functions like your API Gateway:

  • api deploy local - Saves a hapi server at ./local.js
  • api deploy local --serve --watch --sdk - Test your Lambdas @ http://localhost:8000 and generate a connected SDK!
  • api deploy local -sw --sdk - A shortform of the above

You can also generate an SDK:

  • api sdk lambda - Build an SDK that points to your AWS Lambdas (saved at ./sdk-lambda.js)!
    • api sdk apigateway - Build an SDK that points to your API Gateway (saved at ./sdk-apigateway.js)!
  • api sdk local - Build a local server you can run with node local (saved at ./sdk-local.js)!
  • api sdk local --prettify - Build an SDK that is not minified

Use an SDK by including (via Node or Script tag), then:

MyAPI.init( new AWS.Lambda() ); // Only required if using the Lambda SDK

MyAPI.accountsCreate({
    headers: {}, // HTTP Headers
    query: {}, // URL Get Params (eg. /?param=123)
    params: {}, // Dynamic URL segment params (eg. /accounts/{accountID})
    payload: {} // eg. POSTed Data
}, function(err, data) {
    console.log('Response from your API:', err, data);
});

Want to see an example API?

https://github.com/dallasread/api-deploy/tree/master/example-api

TODO

  • Undeploy Resources

Changelog

  • 0.3.14
    • Update to uglify with es6 support