![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
gangway
Advanced tools
Changelog
1.2.0
Readme
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.
Gangway is a factory function that progressively layers configuration
options for building an AJAX request with superagent
.
The first step is invoke Gangway with some options:
var Gangway = require('gangway')
var API = Gangway({
baseURL: 'http://example.com',
headers: {
'x-api-key': 'your-token-for-every-request'
}
})
With default configuration options out of the way, let's add some specific routes.
API.route({
users: {
read: {
method : 'GET',
path : '/users/{id?}' // ? indicates that the parameter is optional
}
}
})
API.users.read()
will now perform a GET request to
/users/{id}
. The ?
in the path option specifies that it is
optional. This is useful when using the same route for index and show
endpoints for resources.
For RESTful resources, adding routes this way can become tedious. Gangway provides another method for quickly building routes for RESTful resources:
// This is equivalent to creating a create, read, update, and destroy
// route. Options are folded into every route.
API.resource("comments", {})
From there, the Gangway instance is ready for use!
// 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' } })
// The same is true for routes added via API.resource
API.comments.read({ params: { id: '2' }})
See the available options below, or consider working through the Hello Gangway guide.
baseURL : The base URL prepended to all requests
body : The request body
headers : Request headers,
method : Request method (GET, POST, PUT, PATCH, DELETE, etc...)
beforeSend : Configure an instance of superagent before the request is sent
onResponse : Run before resolving a request to preprocessing data
onError : Run before rejecting a request to preprocessing errors
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
query : An object of query parameters. Gangway will automatically stringify this into the URL.
Additionally consider skimming through the ./docs folder.
Visit code.viget.com to see more projects from Viget.
FAQs
A client-side API abstraction layer
The npm package gangway receives a total of 97 weekly downloads. As such, gangway popularity was classified as not popular.
We found that gangway demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.