From a9c7cfc4bca28fee2a46485e228aa7655c0c3468 Mon Sep 17 00:00:00 2001 From: abe545 Date: Mon, 10 Mar 2014 23:00:29 -0400 Subject: [PATCH] Added index.js, which is literally hardcoded to list my projects. Edited README.md to include a link to the blog. --- README.md | 3 +++ lib/index.js | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 lib/index.js diff --git a/README.md b/README.md index 634bb2c..357e878 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,6 @@ codeplex-for-strider ==================== A codeplex provider for strider-cd +This is an ongoing project, that I am using as a way to learn node. + +If, for some strange reason you want to follow along, you can follow the progress at http://gettinggui.com \ No newline at end of file diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 0000000..2d5aef5 --- /dev/null +++ b/lib/index.js @@ -0,0 +1,37 @@ +var https = require('https'); +var http = require('http'); + + +http.createServer(function(request, response) { + console.log("Request handler 'codeplex' was called."); + + var options = { + hostname: 'www.codeplex.com', + path: '/api/users/aheidebrecht/projects', + method: 'GET' + }; + + var req = https.request(options, function(res) { + var json = ''; + res.on('data', function(d) { + json += d; + }); + + res.on('end', function() { + var str = JSON.stringify(JSON.parse(json), null, " "); + response.writeHead(200, { 'Content-Type': 'text/plain' }); + response.write(str); + response.end(); + }); + }); + + req.end(); + + req.on('error', function(err) { + console.error(err); + + response.writeHead(500, { 'Content-Type': 'text/plain' }); + response.write(err); + response.end(); + }); +}).listen(999); \ No newline at end of file