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

req-sync

v0.1.5

Published

A synchronous HTTP Client library for node.js

Downloads

3

Readme

req-sync

req-sync is Node.js extension that provides syncronous http request.

Installing

You must have libcurl installed in order to compile this extension.

Ubuntu:

  • sudo apt-get install libcurl4-openssl-dev

CentOS/redhat:

  • sudo yum install libcurl libcurl-devel

Mac:

  • brew install libcurl

Window:

  • compile the openssl/libcurl
  • copy libcurl include floder to node_modules/curl/
  • copy libcurl.lib to node_modules/curl/lib/
  • copy libcurl.dll/libeay32.dll/ssleay32.dll to %PATH%
  • npm install

Using

var rsync = require('req-sync');

//full options.
var ret=rsync.req({
	method: "POST",
	url: "http://xxxx.com/api/",
	args: {
		arg1: "",
	},// or using custom body
	headers: {}, 
	timeout:30000,
	timeout_c:30000,
	cookie: true,//using cookie
	json: true //parse return as json.
});
console.log(ret);
//
//post file
rsync.req({
	method: "POST",
	url: "http://localhost:8334/u",
	cookie: true,
	margs: {
		"aa": "bb",
	},
	mfs: {
		"file": "test/run.js",
	},
	headers: [
		"aaa:bbb"
	],
});
//
//post body
rsync.req({
	method: "POST",
	url: "http://localhost:8334/b",
	cookie: true,
	body: '{"val":"OK"}',
});
//
//post/get
rsync.post("http://www.com/api",{},true);
rsync.get("http://www.com/api",true);

Function

  • req(options) see Options
  • get(url,[json]) send get request.
  • post(url,[args],[json]) send post request.

Options

  • method: POST/GET.
  • url: target URL address.
  • args: the request arguments.
  • headers: the http headers.
  • timeout: the http timeout.
  • timeout_c: the connection timeout.
  • cookie: if setting true, it will using the .cookie as cookie file name. or setting cookie file paht like /tmp/a.cookie.
  • json:whether parse return string as json to javascript object.
  • body: the request body,if it is not empty,the args will be ignore when using POST method.
  • marg: the multipart fileds.
  • mfs: the multipart files.

Return

  • err: the error message,when error occur.
  • length: the reponse content length.
  • headers: the response headers.
  • data: the reponse data.
  • status: the http status code.

Other

  • enable global cookie:require('req-sync').cookie=".cookie"