Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gangway

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gangway

A client-side API abstraction layer

  • 0.6.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
225
decreased by-0.88%
Maintainers
1
Weekly downloads
 
Created
Source

Gangway

A client-side API abstraction layer

Gangway is our general purpose tool for working with APIs on the client-side. It is a thin layer on top of superagent with specific opinions related to how we work.

Circle CI

Overview

Gangway is a factory function that progressively layers configuration options for building an AJAX request with superagent:

let Gangway = require('../src')

let API = Gangway({
  baseURL: 'http://example.com',
  headers: {
    'x-api-key': 'your-token-for-every-request'
  }
})

API.route({
  users: {
    get: {
      method : 'GET',
      path   : '/users/{id*}' // * indicates that the parameter is optional
    }
  }
})

// this will send a request to GET http://example.com/users
API.users.read()

// this will send a request to GET http://example.com/users/10
API.users.read({ params: { id: '10' } })

Documentation

Available options

baseURL    : The base URL prepended to all requests
body       : The request body
method     : Request method (GET, POST, PUT, PATCH, DELETE, etc...)
onResponse : Run before resolving a request for preprocessing data
params     : Populate bindings in paths and are sent as request bodies. Defaults to body.
path       : The path fragment of the endpoint, appended to baseURL
type       : Content type, defaults to JSON

FAQs

Package last updated on 16 Jun 2015

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc