Socket
Socket
Sign inDemoInstall

@heroku/hapi-heroku-client

Package Overview
Dependencies
5
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @heroku/hapi-heroku-client

http client pre-configured to streamline interfacing with heroku's platform API


Version published
Maintainers
1
Created

Readme

Source

hapi-heroku-client Circle CI

a hapijs plugin mapping a heroku client to both server.app.heroku and request.app.heroku, the latter of which includes the incoming requests Authorization header. This project is based on wreck. See wreck's documentation for additional options and usages.

usage

npm install --save hapi hapi-heroku-client
const Hapi = require('hapi');
const myServer = new Hapi.Server();

myServer.connection();
myServer.register([
  {
    register: require('hapi-heroku-client'),
    options: {
      /* options enumerated below */
      'timeout': 5000, /* for example */
      'user-agent': 'example-code-1.0.0' /* for another example */
    }
  }
], function (error) {

    if (error) { throw error; }

    myServer.route({
      method: 'get',
      path: '/foo',
      handler: function (request,reply) {
        const server = request.server;

        // fetch unauthenticated API endpoints
        server.app.heroku.get('/version', (err, version) => {
          reply(version);
        });

        // or with promises
        server.app.heroku.getAsync('/version').then((version) => {
          reply(version);
        });

        // fetch authenticated API endpoint
        request.app.heroku.get('/apps', (err, apps) => {
          reply(apps);
        });

        // or with promises
        request.app.heroku.getAsync(('/apps') => {
          reply(apps);
        });
      }
    });

    myServer.start(() => { console.log('your server has started!'); });
  }
);

options

  • host -- defaults to api.heroku.com
  • proto -- defaults to https
  • timeout -- defaults to 15 seconds
  • variant -- defaults to 'application/vnd.heroku+json; version=3'
  • user-agent -- defaults to hapi-heroku-client

variables

  • HEROKU_API_PROTO -- defaults to https
  • HEROKU_API_HOST -- defaults to api.heroku.com
  • HTTP_TIMEOUT -- defaults to 15 seconds

Keywords

FAQs

Last updated on 12 Jan 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc