From 8d5798fe251244b929a415ca652972c289ece5d2 Mon Sep 17 00:00:00 2001 From: Nizar Venturini Date: Fri, 27 Jun 2014 14:49:56 +0100 Subject: [PATCH 1/5] Add username trenpixster --- lib/plugins/trenpixster/index.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lib/plugins/trenpixster/index.js diff --git a/lib/plugins/trenpixster/index.js b/lib/plugins/trenpixster/index.js new file mode 100644 index 0000000..3dd2de9 --- /dev/null +++ b/lib/plugins/trenpixster/index.js @@ -0,0 +1,25 @@ +'use strict'; + +// Declare internals +var internals = {}; + +// Defaults +internals.defaults = {}; + +exports.register = function(plugin, options, next) { + + plugin.route({ + method: 'GET', + path: '/trenpixster', + handler: function(request, reply) { + reply('don\'t worry, be hapi!'); + } + }); + + next(); +}; + +exports.register.attributes = { + name: 'trenpixster', + version: '0.0.0' +}; From 453b9896f522f79241662713f5fdd7403078f931 Mon Sep 17 00:00:00 2001 From: Nizar Venturini Date: Fri, 27 Jun 2014 16:16:18 +0100 Subject: [PATCH 2/5] Add trenpixster user to participants fixture --- friday-participants.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/friday-participants.json b/friday-participants.json index 4b80c8f..cbad536 100644 --- a/friday-participants.json +++ b/friday-participants.json @@ -27,5 +27,6 @@ "davidfoliveira", "pmarques", "gergelyke", - "anarcastanho" + "anarcastanho", + "trenpixster" ] \ No newline at end of file From db2e35eb9a727647cd6c3f019e60429fb4e6a818 Mon Sep 17 00:00:00 2001 From: Nizar Venturini Date: Fri, 27 Jun 2014 16:19:23 +0100 Subject: [PATCH 3/5] Add tests directory to trenpixster user --- test/plugins/trenpixster/index.js | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 test/plugins/trenpixster/index.js diff --git a/test/plugins/trenpixster/index.js b/test/plugins/trenpixster/index.js new file mode 100644 index 0000000..645a59d --- /dev/null +++ b/test/plugins/trenpixster/index.js @@ -0,0 +1,51 @@ +'use strict'; + +var Lab = require('lab'), + Hapi = require('hapi'), + Plugin = require('../../../lib/plugins/trenpixster'); + +var describe = Lab.experiment; +var it = Lab.test; +var expect = Lab.expect; +var before = Lab.before; +var after = Lab.after; + +describe('trenpixster', function() { + var server = new Hapi.Server(); + it('Plugin successfully loads', function(done) { + server.pack.register(Plugin, function(err) { + + expect(err).to.not.exist; + + done(); + }); + }); + + it('Plugin registers routes', function(done) { + var table = server.table(); + + expect(table).to.have.length(1); + expect(table[0].path).to.equal('/trenpixster'); + + done(); + }); + + it('Plugin route responses', function(done) { + var table = server.table(); + + expect(table).to.have.length(1); + expect(table[0].path).to.equal('/trenpixster'); + + var request = { + method: 'GET', + url: '/trenpixster' + }; + + server.inject(request, function(res) { + expect(res.statusCode).to.equal(200); + expect(res.result).to.equal('don\'t worry, be hapi!'); + done(); + }); + + }); +}); From 86a4e3cecd2e5aa2d54cef43c7c3331d4fcfed38 Mon Sep 17 00:00:00 2001 From: Nizar Venturini Date: Fri, 27 Jun 2014 16:27:53 +0100 Subject: [PATCH 4/5] Add proxy url --- lib/plugins/trenpixster/index.js | 10 ++++++++++ test/plugins/trenpixster/index.js | 10 ++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/plugins/trenpixster/index.js b/lib/plugins/trenpixster/index.js index 3dd2de9..bd2a0b0 100644 --- a/lib/plugins/trenpixster/index.js +++ b/lib/plugins/trenpixster/index.js @@ -5,6 +5,10 @@ var internals = {}; // Defaults internals.defaults = {}; +var mapper = function(request, callback) { + callback(null, "http://trenpixster.github.io/"); +} +var handler = { proxy: { mapUri: mapper } }; exports.register = function(plugin, options, next) { @@ -16,6 +20,12 @@ exports.register = function(plugin, options, next) { } }); + plugin.route({ + method: 'GET', + path: '/trenpixster-proxy', + handler: handler + }); + next(); }; diff --git a/test/plugins/trenpixster/index.js b/test/plugins/trenpixster/index.js index 645a59d..47c31e2 100644 --- a/test/plugins/trenpixster/index.js +++ b/test/plugins/trenpixster/index.js @@ -24,8 +24,9 @@ describe('trenpixster', function() { it('Plugin registers routes', function(done) { var table = server.table(); - expect(table).to.have.length(1); + expect(table).to.have.length(2); expect(table[0].path).to.equal('/trenpixster'); + expect(table[1].path).to.equal('/trenpixster-proxy'); done(); }); @@ -33,17 +34,18 @@ describe('trenpixster', function() { it('Plugin route responses', function(done) { var table = server.table(); - expect(table).to.have.length(1); + expect(table).to.have.length(2); expect(table[0].path).to.equal('/trenpixster'); + expect(table[1].path).to.equal('/trenpixster-proxy'); var request = { method: 'GET', - url: '/trenpixster' + url: '/trenpixster-proxy' }; server.inject(request, function(res) { expect(res.statusCode).to.equal(200); - expect(res.result).to.equal('don\'t worry, be hapi!'); + expect(res.result).to.contain('trenpixster'); done(); }); From c8c238076c7aca8edd01076de5187516c0ecead1 Mon Sep 17 00:00:00 2001 From: Nizar Venturini Date: Fri, 27 Jun 2014 16:46:38 +0100 Subject: [PATCH 5/5] Add my username --- participants.js | 5 +++-- participants.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/participants.js b/participants.js index 9b965c4..ee973a3 100644 --- a/participants.js +++ b/participants.js @@ -1,5 +1,5 @@ var fs = require('fs'); -var participants = [ +var participants = [ 'joaquimserafim', 'nunoveloso', 'satazor', @@ -56,7 +56,8 @@ var participants = [ 'catarinamoura', 'yrezgui', 'pmiguelrn', - 'nihildacta' + 'nihildacta', + 'trenpixster' ]; // var saturday = [ diff --git a/participants.json b/participants.json index 818862a..59b7c03 100644 --- a/participants.json +++ b/participants.json @@ -1,4 +1,4 @@ -[ +[ "joaquimserafim", "nunoveloso", "satazor", @@ -55,5 +55,6 @@ "catarinamoura", "yrezgui", "pmiguelrn", - "nihildacta" + "nihildacta", + "trenpixster" ] \ No newline at end of file