Permalink
Browse files

upgrade to hapi 8

  • Loading branch information...
robertkowalski committed Dec 24, 2014
1 parent 942af67 commit 25eb5abaf5082a92d479b3e6f7b92aeaf392a71d
@@ -13,9 +13,10 @@ var options = {url: '/imprint'},
server;
before(function (done) {
server = Hapi.createServer();
server.pack.register({
plugin: about,
server = new Hapi.Server();
server.connection();
server.register({
register: about,
options: getViewPath({
views: config.server.views
}, 'about')
@@ -25,8 +26,7 @@ before(function (done) {
describe('Imprint', function () {
it('is routed properly', function (done) {
var table = server.table();
expect(table[0].settings.path).to.equal('/imprint');
expect(table[0].table[0].path).to.equal('/imprint');
done();
});
@@ -1,4 +1,4 @@
var Hapi = require('hapi'),
var Boom = require('boom'),
Joi = require('joi');
function getVotesFromCookie (request) {
@@ -61,7 +61,7 @@ exports.register = function Submissions (facet, options, next) {
request.server.methods.getSubmissionById(request.params.id, function (err, doc) {
if (!doc || !doc._id) {
return reply(Hapi.error.notFound('Id not found'));
return reply(Boom.notFound('Id not found'));
}
if (doc.responseTo) {
@@ -90,7 +90,7 @@ exports.register = function Submissions (facet, options, next) {
request.server.methods.getSubmissionById(request.params.id, function (err, doc) {
if (!doc || !doc._id) {
return reply(Hapi.error.notFound('Id not found'));
return reply(Boom.notFound('Id not found'));
}
request.server.methods.getResponsesForInterest(doc._id, function (err, responses) {
@@ -143,7 +143,7 @@ exports.register = function Submissions (facet, options, next) {
var payload = request.payload;
payload.type = 'interest';
request.server.methods.saveSubmission(payload, function (err, doc) {
reply().redirect('interests/' + doc.id);
reply().redirect('/interests/' + doc.id);
});
}
});
@@ -168,7 +168,7 @@ exports.register = function Submissions (facet, options, next) {
payload.responseTo = payload.interest;
}
request.server.methods.saveSubmission(payload, function (err, doc) {
reply().redirect('contributions/' + doc.id);
reply().redirect('/contributions/' + doc.id);
});
}
});
@@ -189,7 +189,7 @@ exports.register = function Submissions (facet, options, next) {
votes = getVotesFromCookie(request);
if (votes.indexOf(submissionId) !== -1) {
error = Hapi.error.badRequest();
error = Boom.badRequest();
reply(error);
return;
}
@@ -15,9 +15,10 @@ var options = {url: '/contributions/someid'},
var fakeData = require('./fixtures/ci.json');
before(function (done) {
server = Hapi.createServer();
server.pack.register({
plugin: submissions,
server = new Hapi.Server();
server.connection();
server.register({
register: submissions,
options: getViewPath({
views: config.server.views
}, 'submissions')
@@ -15,9 +15,10 @@ var options = {url: '/'},
var fakeData = require('./fixtures/ci.json');
before(function (done) {
server = Hapi.createServer();
server.pack.register({
plugin: submissions,
server = new Hapi.Server();
server.connection();
server.register({
register: submissions,
options: getViewPath({
views: config.server.views
}, 'submissions')
@@ -15,9 +15,10 @@ var options = {url: '/interests/someid'},
var fakeData = require('./fixtures/ci.json');
before(function (done) {
server = Hapi.createServer();
server.pack.register({
plugin: submissions,
server = new Hapi.Server();
server.connection();
server.register({
register: submissions,
options: getViewPath({
views: config.server.views
}, 'submissions')
@@ -11,9 +11,10 @@ var Hapi = require('hapi'),
var server;
before(function (done) {
server = Hapi.createServer();
server.pack.register({
plugin: submissions,
server = new Hapi.Server();
server.connection();
server.register({
register: submissions,
options: getViewPath({
views: config.server.views
}, 'submissions')
@@ -11,9 +11,10 @@ var Hapi = require('hapi'),
var server;
before(function (done) {
server = Hapi.createServer();
server.pack.register({
plugin: submissions,
server = new Hapi.Server();
server.connection();
server.register({
register: submissions,
options: getViewPath({
views: config.server.views
}, 'submissions')
@@ -25,9 +25,10 @@
},
"homepage": "https://github.com/jsunconf/contriboot",
"dependencies": {
"boom": "~2.6.1",
"couch-login": "^1.0.0",
"handlebars": "^2.0.0-alpha.4",
"hapi": "~7.5.3",
"hapi": "~8.0.0",
"hoek": "^2.3.0",
"joi": "^4.6.1",
"request": "^2.36.0"
@@ -2,7 +2,11 @@ var Hapi = require('hapi'),
config = require('./config.js'),
getViewPath = config.getViewPath;
var server = Hapi.createServer(config.host, config.port);
var server = new Hapi.Server();
server.connection({
host: config.host,
port: config.port
});
server.views(config.server.views);
server.route({
@@ -17,22 +21,24 @@ server.route({
}
});
server.pack.register([{
plugin: require('./facets/about'),
server.register([
{
register: require('./facets/about'),
options: getViewPath({
views: config.server.views
}, 'about')
},
{
plugin: require('./facets/submissions'),
register: require('./facets/submissions'),
options: getViewPath({
views: config.server.views
}, 'submissions')
},
{
options: config.couch,
plugin: require('./services/data')
register: require('./services/data'),
options: config.couch
}], function (err) {
if (err) {
throw err;
}

0 comments on commit 25eb5ab

Please sign in to comment.