Git Product home page Git Product logo

nodetask's Introduction

Privicee NodeTask

Node.js module โ€“ HTTP GET/POST

Please build a module using the request package that has two methods, getURL and postURL. You can think of it as a simple wrapper around request.

moduleName.getURL(url, callback); // url: path to GET url,
                                  // callback: function of type (err, statusCode, body)

moduleName.postURL(url, jsonData, callback); // url path to POST,
                                             // jsonData: json obj to post to server,
                                             // callback: same as above

Required:

  1. Mocha, write tests for this module
  2. Use the debug module for your debug message. Set debug type to worker. Use debug messages in your module!
  3. Method getUrl - take a URL, ensure it is not null or empty string, then perform GET request. Return error if request returns error object or if statusCode !== 200. Otherwise return null for the error and pass the body back to the callback.
  4. Method postURL - take URL, ensure it is not null or empty string, take postData, ensure it is not null or undefined, then post the JSON data to the server. Return error if request returns error or if statusCode !== 200. Otherwise return null for the error and pass the body back to the callback.

Your Mocha test should check for the following:

  1. Successful getURL using github.com
  2. Successful postURL using posttestserver.com (this will allow you to see your POST data publically follow the URL in the return body.) Please post something silly like your name and current time for testing.
  3. Pass in null to getURL and make sure it gets error back.

Installation

Get it on github, not on npm yet :(

Usage

var nodetask = require('nodetask');

nodetask.getUrl('http://www.url.com', function(err, statusCode, body) {
    console.log(err, statusCode, body);
});

nodetask.postUrl('http://www.url.com', {key1: 'value1', key2: 'value2'}, function(err, statusCode, body) {
    console.log(err, statusCode, body);
});

Tests

npm test

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

Release History

  • 0.1.0 Initial release

nodetask's People

Contributors

jvillasante avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.