ghify-request

1.0.2 • Public • Published

ghify-request

NPM version Build Status Coverage Status Dependency Status devDependency Status

Create a Request wrapper to interact with the GitHub API

const ghifyRequest = require('ghify-request');
const request = require('request');
 
const ghifiedRequest = ghifyRequest(request);
ghifiedRequest('users/shinnn', (err, response, body) => {
  body.login; //=> 'shinnn'
})

Installation

Use npm.

npm install ghify-request

API

const ghifyRequest = require('ghify-request');

ghifyRequest(request[, options])

request: Function (Request function)
options: Object (Request options)
Return: Function (new Request wrapper)

It returns a Request wrapper that defaults to the options for easily interacting with the GitHub API.

options.token

Type: String
Default: process.env.GITHUB_TOKEN

Use specific GitHub access token.

const ghifyRequest = require('ghify-request');
const request = require('request');
 
// https://developer.github.com/v3/gists/#star-a-gist
ghifyRequest(request, {
  token: 'xxxxxxx' // your personal access token
}).put({
  uri: '/gists/908bced575270f6ef80e/star'
}).on('response', () => {
  console.log('Starred the gist https://gist.github.com/shinnn/908bced575270f6ef80e.');
});

options.baseUrl

Type: String
Default: process.env.GITHUB_ENDPOINT if available, otherwise 'https://api.github.com'

Use the different endpoint to support Github enterprise.

License

Copyright (c) 2015 - 2016 Shinnosuke Watanabe

Licensed under the MIT License.

Package Sidebar

Install

npm i ghify-request

Weekly Downloads

2

Version

1.0.2

License

MIT

Last publish

Collaborators

  • shinnn