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

tinycurl

v0.0.4

Published

Tiny curl wrapper. Can solve problems with making requests

Downloads

12

Readme

tinycurl is a tiny node wrapper for the command line curl

$ npm install tinycurl

Reason

Node.js doesn't give some features that curl provides. I was playing with ssl post request for use a remote SOAP service for 3 days. I've wrote 5 solutions in this period, tried pfx, pem, p12, different headers, enabling\disabling security, but it still don't work. I had some progress in making GET request, but I need POST. Maybe reason was in wrong cerificates or our partner don't give us a CA or maybe I have got not right curved hands. After all I'd used SOAP UI desktop tool and it somehow did that request. After 20 minutes spent for reading curl docs, I was able to make this request with a warning.

Finally node-soap && curlrequest modules in npm are depended on some windows stuff and their code is an overkill for this task.

When you should use it

  • Curl have got some features that node.js doesn't and you need it
  • If you stubbed with something about SSL

When you should avoid of using it

  • When node.js native implementation suits

Usage

Make a request with curl - callback receives (err, data) on request completion

var curl = require( 'tinycurl' );


curl.post( 'https://test.com', {
    // tinycurl make an assumption that all keys with
    // length <3 need to be prefixed with two dashes
    // maybe it's wrong
    headers: [ // headers are an array
        'SOAPAction: http://test.com/serviceprovider/TheService/Act',
        'Content-type: text/xml; charser=utf-8'
    ],
    key: 'key.pem',
    cert: 'cert.pem',

    // you can put multiline data here
    // but if you want to use objects - you have to JSON.stringify
    // them or serialize any other way that you want
    // you even can write a tinycurl extension for it
    data: 'hello'
}, callback );

Extending tinycurl

var convertions = curl.getConvert(); // hash of conversion functions

convertions.myCoolFeature = function( val, args ){
    // it's a pure function. val is a value of option and args is
    // an array with all rules. order is using for command line options sort
    args.push({order:2, data: ['-CoolFeature', val]});
}

Predefined request types wrapper

  • curl.request( url, options, callback );
  • curl.post( url, options, callback );
  • curl.get( url, options, callback );

Low level

If you want to handle curl stdout\stderr data when it comes - you can use the output observable object

var req = curl.request( url, options, callback );
req.on( 'stdout', function( data ){
    // whatever
} );

If you want to handle real low level of process - use option "low". It would return a real child_process.spawn object.

var req = curl.request( url, {low: true}, callback );
req.stderr.on( 'data', function( data ){
    console.log('oh no!');
} );

Options

Read "man curl".

License

Copyright (c) 2014 Zibx [email protected] The MIT License (MIT) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.