How to use the request-compose.extend function in request-compose

To help you get started, we’ve selected a few request-compose examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github simov / grant / lib / client.js View on Github external
// some providers return wrong `content-type` like: text/html or text/plain
  else {
    try {
      body = JSON.parse(body)
    }
    catch (err) {
      // use qs instead of querystring for nested objects
      body = qs.parse(body)
    }
  }

  return {options, res, body, raw}
}

module.exports = require('request-compose').extend({
  Request: {oauth: require('request-oauth')},
  Response: {parse}
}).client
github simov / grant / test / consumer / flow.js View on Github external
var t = require('assert')

var request = require('request-compose').extend({
  Request: {cookie: require('request-cookie').Request},
  Response: {cookie: require('request-cookie').Response},
}).client

var hapi = parseInt(require('hapi/package.json').version.split('.')[0])

var port = {auth: 5000, app: 5001}
var url = {
  auth: (path) => `http://localhost:${port.auth}${path}`,
  app: (path) => `http://localhost:${port.app}${path}`,
}

var provider = require('./util/provider')
var client = require('./util/client')
github simov / grant / test / consumer / session.js View on Github external
var t = require('assert')

var request = require('request-compose').extend({
  Request: {cookie: require('request-cookie').Request},
  Response: {cookie: require('request-cookie').Response},
}).client

var hapi = parseInt(require('hapi/package.json').version.split('.')[0])

var port = {oauth1: 5000, oauth2: 5001, app: 5002}
var url = {
  oauth1: (path) => `http://localhost:${port.oauth1}${path}`,
  oauth2: (path) => `http://localhost:${port.oauth2}${path}`,
  app: (path) => `http://localhost:${port.app}${path}`,
}

var provider = require('./util/provider')
var client = require('./util/client')
github simov / grant / test / consumer / error.js View on Github external
var t = require('assert')
var urlib = require('url')
var http = require('http')
var qs = require('qs')

var request = require('request-compose').extend({
  Request: {cookie: require('request-cookie').Request},
  Response: {cookie: require('request-cookie').Response},
}).client

var express = require('express')
var session = require('express-session')

var Koa = require('koa')
var koasession = require('koa-session')
var mount = require('koa-mount')
var convert = require('koa-convert')
var koaqs = require('koa-qs')

var Hapi = require('hapi')
var yar = require('yar')
github simov / grant / test / consumer / middleware.js View on Github external
var t = require('assert')

var request = require('request-compose').extend({
  Request: {cookie: require('request-cookie').Request},
  Response: {cookie: require('request-cookie').Response},
}).client

var port = {oauth2: 5001, app: 5002}
var url = {
  oauth2: (path) => `http://localhost:${port.oauth2}${path}`,
  app: (path) => `http://localhost:${port.app}${path}`,
}

var provider = require('./util/provider')
var client = require('./util/client')


describe('middleware', () => {
  var server = {oauth2: null}
github simov / grant / examples / user-profile / app.js View on Github external
var express = require('express')
var session = require('express-session')
var grant = require('grant-express')

var request = require('request-compose').extend({
  Request: {oauth: require('request-oauth')}
}).client

var config = require('./config.json')


express()
  .use(session({secret: 'grant', saveUninitialized: true, resave: true}))
  .use(grant(config))

  .get('/hello', async (req, res) => {
    var {body} = await request({
      url: 'https://graph.facebook.com/me',
      headers: {authorization: `Bearer ${req.query.access_token}`}
    })
    res.end(JSON.stringify({oauth: req.query, profile: body}, null, 2))

request-compose

Composable HTTP Client

Apache-2.0
Latest version published 2 months ago

Package Health Score

70 / 100
Full package analysis