npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

chain-request

v0.0.7

Published

A simple chainable, readable object with the intense to make speaking HTTP sane.

Downloads

26

Readme

chain-request

A simple chainable, readable object with the intense to make speaking HTTP sane.

Installation

> npm install --save chain-request

Usage

Just include the module and name it, e.g.:

var request = require('chain-request');

Examples

Use the google REST-API

new request()
	.get('http://ajax.googleapis.com/ajax/services/search/web')
	.expects(request.CONTENT_TYPE.JSON)
	.data({
		v: '1.0',
		q: 'test'
	})
	.send(function(data) {
		data.responseData.results.forEach(function(result) {
			console.log(result);
		});
	});

Upload a file with authorization Header

new request()
	.post('https://build.phonegap.com/api/v1/apps')
	.expects(request.CONTENT_TYPE.JSON)
	.addAuthorizationHeader('Basic: a2Vrc2U6a3VjaGVu')
	.data('app.zip')
	.sendMultipart()
	.send(function(result) {
		console.log(result);
	})

Get a specific jira task

new request()
	.get('https://my-jira.tld/rest/api/2/issue/FOO-39')
	.expects(request.CONTENT_TYPE.JSON)
	.addAuthorizationHeader('Basic: a2Vrc2U6a3VjaGVu')
	.send(function(result) {
		console.log(result);
	})

API

Functions

Kind: global function

| Param | Type | Default | Description | | --- | --- | --- | --- | | [debug] | boolean | false | enable debugging with true |

get() ⇒ object

make a get request

Kind: global function
Returns: object - self

put() ⇒ object

make a put request

Kind: global function
Returns: object - self

post() ⇒ object

make a post request

Kind: global function
Returns: object - self

patch() ⇒ object

make a patch request

delete() ⇒ object

make a delete request

Kind: global function
Returns: object - self

options() ⇒ object

make a options request

Kind: global function
Returns: object - self

head() ⇒ object

make a head request

Kind: global function
Returns: object - self

Kind: global function
Returns: object - self

data(data) ⇒ object

set the data for the request

Kind: global function
Returns: object - self

| Param | Type | Description | | --- | --- | --- | | data | object | data as json object |

addHeader(key, value) ⇒ object

add a header

Kind: global function
Returns: object - self

| Param | Type | Description | | --- | --- | --- | | key | string | header key | | value | string | value of the header entry |

allowUnauthorized() ⇒ object

Don't verifie against the list of supplied CAs.

Kind: global function
Returns: object - self

addAuthorizationHeader(authStr) ⇒ object

set a authorization header

Kind: global function
Returns: object - self

| Param | Type | Description | | --- | --- | --- | | authStr | string | authirization string |

setSendContentType(contentType) ⇒ object

set which type of format you want to send, default ist json

Kind: global function
Returns: object - self

| Param | Type | Description | | --- | --- | --- | | contentType | object | a valid content type |

sendsPlain() ⇒ object

function to send plain text to the server only make sense with post or put

Kind: global function
Returns: object - self

sendMultipart() ⇒ object

defines a multipart request for files, used with post() and data(filename)

Kind: global function
Returns: object - self

setBufferSize(bufferSize) ⇒ object

set the buffer size for a multipart request default is 4 * 1024

Kind: global function
Returns: object - self

| Param | Type | Description | | --- | --- | --- | | bufferSize | number | size in byte |

setEncoding(encoding) ⇒ object

set the response encoding, default is utf-8

Kind: global function
Returns: object - self

| Param | Type | Description | | --- | --- | --- | | encoding | string | a valid encoding |

expects(type) ⇒ object

set the format for the send callback, default is json

Kind: global function
Returns: object - self

| Param | Type | Description | | --- | --- | --- | | type | string | a valid content type |

send([callback]) ⇒ object

perform the previously created request

Kind: global function
Returns: object - self

| Param | Type | Description | | --- | --- | --- | | [callback] | function | function called when the request is ready |