Skip to content

Commit

Permalink
Merge branch 'hapi-upgrade'
Browse files Browse the repository at this point in the history
Updates Hapi to v9.x
  • Loading branch information
tribou committed Sep 15, 2015
2 parents c33483e + 5c1538a commit 3577b5e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 31 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
"dependencies": {
"dateformat": "^1.0.11",
"flux": "^2.0.3",
"hapi": "^8.8.0",
"hapi": "^9.3.1",
"hapi-react-views": "^3.0.1",
"inert": "^3.0.1",
"object-assign": "^3.0.0",
"react": "^0.13.3",
"superagent": "^1.2.0"
"superagent": "^1.2.0",
"vision": "^3.0.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
Expand Down
72 changes: 43 additions & 29 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,51 @@ server.connection({
port: 8000
});

// Add the React-rendering view engine
server.views({
engines: {
jsx: require('hapi-react-views')
},
relativeTo: __dirname,
path: 'views'
});
// Register the inert and vision Hapi plugins
// As of Hapi 9.x, these two plugins are no longer
// included in Hapi automatically
// https://github.com/hapijs/hapi/issues/2682
server.register([{
register: require('inert')
}, {
register: require('vision')
}], function(err) {

// Add a route to serve static assets (CSS, JS, IMG)
server.route({
method: 'GET',
path: '/{param*}',
handler: {
directory: {
path: 'assets',
index: ['index.html']
}
}
});
if (err) return console.error(err);

// Add main app route
server.route({
method: 'GET',
path: '/',
handler: {
view: 'Default'
}
});
// Add the React-rendering view engine
server.views({
engines: {
jsx: require('hapi-react-views')
},
relativeTo: __dirname,
path: 'views'
});

// Add a route to serve static assets (CSS, JS, IMG)
server.route({
method: 'GET',
path: '/{param*}',
handler: {
directory: {
path: 'assets',
index: ['index.html']
}
}
});

// Add main app route
server.route({
method: 'GET',
path: '/',
handler: {
view: 'Default'
}
});

server.start(function() {
console.log(dateFormat(new Date(), format) + ' - Server started at: ' + server.info.uri);
});

server.start(function() {
console.log(dateFormat(new Date(), format) + ' - Server started at: ' + server.info.uri);
});

0 comments on commit 3577b5e

Please sign in to comment.