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

quest

v0.4.0

Published

simple request library for node

Downloads

1,056

Readme

Quest - massively simplified, super lightweight HTTP requests

Build Status

Install

npm install quest

Super simple to use

Quest is the simplest way to make http calls, as well as a drop-in replacement for the popular request library. It supports HTTPS and follows redirects by default.

quest = require 'quest'
quest 'www.google.com', (err, response, body) ->
  console.log body if not err? and response.statusCode is 200

Supported options

  • uri - fully qualified uri (e.g. http://google.com). if protocol is left off, assumes http://. may include basic auth
  • auth - a string of the form username:password to be used for http basic auth
  • qs - object containing querystring values to be appended to the uri
  • method - http method, defaults to GET
  • headers - http headers, defaults to {}
  • body - entity body for POST and PUT requests. must be string
  • form - object containing form values to send in the body. also adds content-type: application/x-www-form-urlencoded; charset=utf-8 to the header
  • json - if true, parses response as JSON. if object, additionally sends JSON representation of the object in the body and adds content-type: application/json to the header
  • followRedirects - follow HTTP 3xx responses as redirects. defaults to true
  • followAllRedirects - follow non-GET HTTP 3xx responses as redirects. defaults to false
  • maxRedirects - the maximum number of redirects to follow. defaults to 10
  • jar - cookies are enabled by default. set to false to disable. optionally pass in your own custom cookie jar (see Cookies below)
  • timeout - integer containing the number of milliseconds to wait for a request to respond before aborting the request

The options object is passed in instead of a url string.

quest = require 'quest'

options =
  uri: 'www.google.com'
  method: "POST"

quest options, (err, response, body) ->
  console.log body if not err? and response.statusCode is 200

Cookies

Cookies are enabled by default. This means that if your requests involved redirection, any redirects will contain cookies set prior. To disable cookies, set jar to false.

If you want to use a custom cookie jar (instead of letting quest use its own default cookie jar) you do so by specifying a jar as an option:

j = quest.jar()
quest {uri: 'www.google.com', jar: j}, () ->
 quest {uri: 'images.google.com', jar: j}, () ->
   # The request to Google images was sent with any cookies that were set by the original request to Google

Note that any cookies that earlier requests set are set in your custom jar, so you can use them for later requests. You can also set your own cookies when you specify a jar:

j = quest.jar()
cookie = quest.cookie 'your_cookie_here'
j.add cookie
quest {uri: 'www.google.com', jar: j}, (err, resp, body) ->
  # The request to Google was sent with the cookie that you specified

Promises

Quest also supports ES6 Promises.

quest = require 'quest'

quest 'www.google.com'
  .then (response) ->
    console.log response.body if response.statusCode is 200
  , (err) ->
    console.log err

Vs. request

Clever wrote quest after we had decided we'd spent too long diagnosing bugs in the third-party request module for node. It should be a drop-in replacement. What are the advantages of quest?

  1. No global state

  2. Cleaner codebase: 1/10th as many lines of code

  3. Fewer bugs