{"_id":"requestah","_rev":"31-2fa1e88d703033965d28df55df948ed9","name":"requestah","description":"lean http wrapper that makes unit testing REST apps a bit less rough","dist-tags":{"latest":"1.0.0"},"versions":{"0.1.4":{"name":"requestah","description":"lean http wrapper that makes unit testing REST apps a bit less rough","keywords":["util","http","server","client","rest","testing"],"url":"http://www.theindustry.se","author":{"name":"Joakim B","email":"joakim@theindustry.se"},"contributors":[],"repository":{"type":"git","url":"git://github.com/jockster/requestah.git"},"licenses":[{"type":"MIT"}],"version":"0.1.4","engine":{"node":">=0.6.12"},"main":"requestah.js","_npmUser":{"name":"jockster","email":"joakim@theindustry.se"},"_id":"requestah@0.1.4","dependencies":{},"devDependencies":{},"optionalDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.1.2","_nodeVersion":"v0.8.7","_defaultsLoaded":true,"dist":{"shasum":"46a8609e2abaaaff77598b1003191c7a1345bd42","tarball":"https://registry.npmjs.org/requestah/-/requestah-0.1.4.tgz","integrity":"sha512-6pBM9La0XkyJEb2aRJJPcbXIwuPOAXi2yY0wIcp5kv50Ebghf3Ub2CoPVlBshRwpBRHgFacmJ1xvOsd5jM2NKQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD1WwPrGQo5VFy/aibzm/0Ip8ctJWxIeOZDXWtHaAM3JAIgbURHvaK4z3tar142HWNtbwVpel+KyZq8VCbcltbVzoY="}]},"maintainers":[{"name":"jockster","email":"joakim@theindustry.se"}],"directories":{},"deprecated":"1.0 released"},"1.0.0":{"name":"requestah","description":"lean http wrapper that makes unit testing REST apps a bit less rough","keywords":["util","http","server","client","rest","testing"],"url":"http://www.vaikava.com","author":{"name":"Joakim B","email":"joakim@theindustry.se"},"contributors":[],"repository":{"type":"git","url":"http://github.com/vaikavalabs/requestah.git"},"licenses":[{"type":"MIT"}],"version":"1.0.0","engine":{"node":">=0.6.12"},"main":"./lib/requestah.js","devDependencies":{"coffee-script":"~1.3.3","express":"~3.0.0rc4","mocha":"~1.4.2"},"readme":"requestah\n============\n**lean** HTTP wrapper for `node.js` that makes unit testing your HTTP API's a bit less rough.\n\n       \nInstallation\n============\n\t\n\tnpm install requestah\n\nBasic Usage\n============\n\t\n    var r = require('requestah')(80); // Set the port for future requests\n    \n    // Basic HTTP GET:\n    r.get('/users', function(res) {\n    \tif (res.statusCode === 200) { console.log(res.body); }\n    });\n    \n    // HTTP POST with data:\n    r.post('/users', {name: \"John Doe\"}, function(res) {\n    \tif (res.statusCode === 200) { console.log(res.body); }\n    });\n    \n    // External HTTP GET:\n    r.get('http://www.example.org', function(res) {\n        if (res.statusCode === 302) { console.log(\"We got redirected to \" + res.headers.location); }\n    });\n    \n\nAdvanced usage\n============\n\n \t// HTTP GET with querystrings passed as object\n    r.get('/users', {ageMin: 30, ageMax: 50} function(res, dbg) {\n    \tif (res.statusCode === 200) { console.log(res.body); }\n    });\n    \n    // HTTP GET with querystrings passed in path - performs exactly the same request as above would do\n    r.get('/users?ageMin=30&ageMax=50', function(res, dbg) {\n    \tif (res.statusCode === 200) { console.log(res.body); }\n    });\n    \n    // HTTP DELETE with a header for only this request\n    r.del('/users/john', {headers: {apikey: \"verySecretKey\"}}, function(res) {\n    \tif (res.statusCode === 204) { console.log(res.body); }\n    });\n    \n    // Set a fixed HTTP header for all future requests. Helpful for authentication \n    r.setHeader('apikey', 'b4080ca70d5617...');\n\n    // HTTP PUT with data & headers:\n    r.put('/users/john', {name: \"Jane Doe\", headers: {adminkey: \"IGOTADMINRIGHTS\"}}, function(res, req) {\n    \n    \tif (res.statusCode === 204) { console.log(res.body); }\n    \tconsole.log(req.params); // => params: {name: \"Jane Doe\"}\n    \t\n    \t// Note that both the above set apikey and the per-request adminkey have been sent in the request:\n    \tconsole.log(req.headers); // => headers: {apikey: 'b4080ca70d5617...', adminkey: 'IGOTADMINRIGHTS'}\n    });\n    \n    \n    // HTTP POST with enforced Content-Type:\n    r.post('/users', {name: \"John Doe\", type: \"form\"}, function(res, req) {\n    \tconsole.log(req['Content-Type']); // => 'application/json'\n    });\n\n    // Activate debug mode - future requests will not be performed. Only request options are returned:\n    r.setDebug(true);\n    \n    // Check out the available debug information\n    r.post('/users', {name: \"John Doe\", type: \"form\"}, function(res, req) {\n\t\t\n\t\tconsole.log(res); // res => false\n\t\t\n\t\tconsole.log(req); \n\t\t/*\n\t     req => {\n\t\t    port: 80,\n\t\t    method: 'POST',\n\t\t    path: '/users',\n\t\t    headers: {apikey: 'b4080ca70d5617...', adminkey: 'IGOTADMINRIGHTS'},\n\t\t    'Content-Type': 'application/json'\n\t\t    params: {name: \"John doe\"},\n\t\t    parsedParams: '{\"name\": \"John Doe\"}',\n\t     }\n     \t*/\n\t\t    \n    });\n    \nAPI\n============\n\n`requestah.`\n  * `get(path, data, callback)`\n  * `post(path, data, callback)`\n  * `put(path, data, callback)`\n  * `del(path, data, callback)`\n    * `path` - [REQUIRED] - The URL to fetch. Can be either relative to root, ie. `/users` or but also an full path, `http://www.google.com` \n    * `data` - [OPTIONAL] - The data to be sent along with the request. Is appended automatically as a querystring to the path for HTTP GET requests, or converted into JSON automatically for POST/PUT/DELETE.\n      * `headers` - [OPTIONAL] - The eventual headers to send along with the requests. Does overwrite any previously set fixed headers\n      * `type` - [OPTIONAL] - A way to force content-type -encoding of the request to be either `form` `application/x-www-form-urlencoded`, or `json` (application/json)\n    * `callback` - [REQUIRED] - The callback to be fired once the request is complete. Returns two arguments: `response` & `request`\n    \t* `response` - The actual node response object. False if in debug mode. Please visit the [official node.js documentation] for full documentation : http://nodejs.org/api/http.html#http_class_http_serverrequest\n    \t* `request` - The arguments used to create the request. Useful for debugging and the only argument returned if in debug mode.\n     \n  * `setFixedHeader(key, value)` - Sets a fixed header to be included with all future requests. Useful to set HTTP Auth headers.\n  * `setDebug(bool)` - Activates debugging, which means that no actual HTTP requests will be perfomed. Watch the second argument (request) in the callbacks for detailed debug information.    \t\n\nCheckout the tests in `test/test-main.js` for actual examples and usecases.\n\nLicense\n============\n\nSee `LICENSE` file.\n\n> Copyright (c) 2012 Joakim B\n\n","_id":"requestah@1.0.0","dist":{"shasum":"f8701ad642c106f3d092de6dffa2b46ba0724048","tarball":"https://registry.npmjs.org/requestah/-/requestah-1.0.0.tgz","integrity":"sha512-xhRwVE2htRuhZJrYz5LpUCGGgsKUWLw557LVFOBs/N/E5zMjQRBjLNgE95UvJicV51iF1EzysTXr44ikMf0YXg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHZ3RLUqGtHX7hpSopYLU9jbF23M0EHzRB0grnIw4ylwAiAB7IVMassZru1n6JuAueONVy0tY4sGA71TsQvUCmmEIw=="}]},"_npmVersion":"1.1.59","_npmUser":{"name":"jockster","email":"joakim@brantingson.se"},"maintainers":[{"name":"jockster","email":"joakim@theindustry.se"}]}},"readme":"requestah\n=======\n**lean** HTTP wrapper for `node.js` that makes unit testing your REST services a bit easier.\n\nUsage: \n\n    var requestah = require('requestah');\n    requestah = new requestah(80); // Use any port you want\n    \n    // Basic HTTP GET:\n    requestah.get('/users', function(response) {\n    \tif (response.statusCode === 200) { console.log(response.body); }\n    });\n    \n    // HTTP POST with data:\n    requestah.post('/users', {name: \"John Doe\"}, function(response) {\n    \tif (response.statusCode === 200) { console.log(response.body); }\n    });\n    \n    // HTTP DELETE with headers:\n    requestah.del('/users/john', {headers: {authkey: \"b4080ca70d561714e3245f6ed4b8d243\"}}, function(response) {\n    \tif (response.statusCode === 204) { console.log(response.body); }\n    });\n    \n    // HTTP PUT with data & headers:\n    requestah.put('/users/john', {name: \"Jane Doe\", headers: {authkey: \"b4080ca70d561714e3245f6ed4b8d243\"}}, function(response) {\n    \tif (response.statusCode === 204) { console.log(response.body); }\n    });\n    \n\n    // External HTTP GET:\n    requestah.get('http://www.google.com', function(response) {\n\t    if (response.statusCode === 200) { console.log(response.body); }\n\t});\n       \n       \nlicense\n-------\n\nSee `LICENSE` file.\n\n> Copyright (c) 2012 Joakim Brantingson\n\n","maintainers":[{"name":"jockster","email":"joakim@theindustry.se"}],"time":{"modified":"2022-06-26T11:34:23.067Z","created":"2012-03-18T22:16:22.722Z","0.1.0":"2012-03-18T22:16:30.077Z","0.1.1":"2012-03-20T18:38:06.095Z","0.1.2":"2012-08-28T13:09:26.562Z","0.1.3":"2012-08-29T09:39:18.632Z","0.1.4":"2012-08-29T11:30:43.314Z","1.0.0":"2012-09-13T11:00:34.062Z"},"author":{"name":"Joakim B","email":"joakim@theindustry.se"},"repository":{"type":"git","url":"http://github.com/vaikavalabs/requestah.git"}}