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

eden-rest

v0.0.32

Published

Eden Node JS General REST Methods

Downloads

34

Readme

#Rest

DESCRIPTION

Build Status

General

Installation

npm install eden-rest

Usage

var rest = require('eden-rest');

Methods


setAuthentication

 this setAuthentication( '[email protected]','yourpassword' );

Sets authentication

Parameters

  1. '[email protected]' - string (username)

  2. 'yourpassword' - string (password)

Returns

this

Example

Code
var username = '[email protected]';
var password = 'yourpassword';
rest().setAuthentication(username, password);
typeof result;
Outputs
'object'

setBody

 this setBody( 'id=123&trim_user=false' );

Sets the request body

Parameters

  1. 'id=123&trim_user=false' - string

Returns

this

Example

Code
rest().setBody('id=123&trim_user=false');
typeof response;
Outputs
'string'

setQueryBody

 this setQueryBody( {id: '123', trim_user: false} );

Sets the request body from an object to a string query

Parameters

  1. {id: '123', trim_user: false} - object

Returns

this

Example

Code
rest().setQueryBody({id: '123', trim_user: false});
Outputs
'object'

setJsonBody

 this setJsonBody({id: '123', trim_user: false});

Sets the request body from an object to JSON

Parameters

  1. {id: '123', trim_user: false} - object

Returns

this

Example

Code
rest().setJsonBody({id: '123', trim_user: false});
typeof response;
Outputs
'object'

setHeaders

 this setHeaders('https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json', 'http://tinyurl.com/zhy5');

Sets the headers hash

Parameters

  1. string|object

  2. mixed

Returns

this

Example

Code
var url = 'https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json';
rest().setHeaders(url , 'http://tinyurl.com/zhy5');
Outputs
'string'

setHost

 this setHost('https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json');

Sets the URL host

Parameters

  1. 'https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json' - string (url)

Returns

this

Example

Code
var url = 'https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json';
var result = rest().setHost(url);
Outputs
'https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json'

setMethod

 this setMethod('post');

Sets the method IE GET, POST, PUT, DELETE

Parameters

  1. 'post' - string

Returns

this

Example

Code
var url = 'https://apiu.twitter.com/1.1/statuses/retweet/241259202004267009.json';
rest()
.setUrl(url)
.setMethod('post');
Outputs
'object'

setPath

 this setPath('https://apiu.twitter.com/1.1/statuses/retweet/241259202004267009.json');

Sets the url path

Parameters

  1. 'https://apiu.twitter.com/1.1/statuses/retweet/241259202004267009.json' - string (url)

Returns

this

Example

Code
var url = 'https://apiu.twitter.com/1.1/statuses/retweet/241259202004267009.json';
rest().setPath(url);
Outputs
'https://apiu.twitter.com/1.1/statuses/retweet/241259202004267009.json'

setPort

 this setPort(3306);

Sets the port

Parameters

  1. 3306 - int (port number)

Returns

this

Example

Code
var port = 3306;
rest().setPort(port);
Outputs
'3306'

setUrl

 this setUrl('https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json');

Disects URL

Parameters

  1. 'https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json' - string (url)

Returns

this

Example

Code
var url = 'https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json';
rest().setUrl(url);
Outputs
'https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json'

useSSL

 this useSSL('https://apiu.twitter.com/1.1/statuses/retweet/241259202004267009.json');

Use HTTPS

Parameters

Returns

this

Example

Code
var url = 'https://apiu.twitter.com/1.1/statuses/retweet/241259202004267009.json';
rest().useSSL(url);
typeof response;
Outputs
'string'

getResponse

 this getResponse(function, string);

Sends off the request

Parameters

  1. function(error, response) - function

  2. 'https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json' - string

Returns

this

Example

Code
var url = 'https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json';
rest().setUrl(url);
rest().getResponse(function(error, response));
Outputs
'https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json'

getJsonResponse

 this getJsonResponse(Function, String);

Sends off the request

Parameters

  1. function

  2. string

Returns

this

Example

Code
var url = 'https://apiu.twitter.com/1.1/statuses/retweet/241259202004267009.json';
rest()
.setUrl(url)
.setMethod('post')
.setBody('id=123&trim_user=false')
.getJsonResponse(function(error, response,meta))
Outputs
'object'

getQueryResponse

 this getQueryResponse(Function, String);

Sends off the request

Parameters

  1. function

  2. string

Returns

this

Example

Code
var url = 'https://apiu.twitter.com/1.1/statuses/retweet/241259202004267009.json';
rest()
.setUrl(url)
.setMethod('post')
.setQueryBody({id: '123', trim_user: false})
.getQueryResponse(function(error, response));
typeof response;
Outputs
'object'