Skip to content

Commit

Permalink
adds inert & vision to deps for serving static and views respectively.
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Aug 14, 2015
1 parent bd8bab2 commit 394df5b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 29 deletions.
62 changes: 34 additions & 28 deletions examples/staticfiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,44 @@ var Hapi = require('hapi');
var server = new Hapi.Server();
var port = process.env.PORT || 5000;

server.connection({ port: port });
var plugins = [
require('inert'), // serve static content
require('vision') // views
]
server.register(plugins, function () {
server.connection({ port: port });

server.views({
engines: {
html: require('handlebars')
},
path: Path.join(__dirname, 'views')
});
server.views({
engines: {
html: require('handlebars')
},
path: Path.join(__dirname, 'views')
});

server.route([
{ path: '/',
method: 'GET',
config: {
auth: false,
handler: function(request, reply) {
reply.view("index");
}
}
},
{
method: 'GET',
path: '/public/{param*}',
handler: {
directory: {
path: Path.normalize(__dirname + '/public')
server.route([
{ path: '/',
method: 'GET',
config: {
auth: false,
handler: function(request, reply) {
reply.view("index");
}
}
},
{
method: 'GET',
path: '/public/{param*}',
handler: {
directory: {
path: Path.normalize(__dirname + '/public')
}
}
}
}
]);
]);

server.start(function(){
console.log('Static Server Listening on : http://127.0.0.1:' +port);
server.start(function(){
console.log('Static Server Listening on : http://127.0.0.1:' +port);
});
});

module.exports = server;
module.exports = server;
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
"boom": "^2.8.0",
"handlebars": "^3.0.3",
"hapi": "^9.0.1",
"inert": "^3.0.1",
"joi": "^6.6.1",
"socket.io": "^1.3.6"
"socket.io": "^1.3.6",
"vision": "^2.0.1"
},
"devDependencies": {
"code": "^1.5.0",
Expand Down

0 comments on commit 394df5b

Please sign in to comment.