ryanmurakami / pluralsight-hapi-starter-code

Contains the starter code for the Building Web Applications with hapi course on Pluralsight.com.
http://www.pluralsight.com/courses/hapi-building-web-applications
9 stars 8 forks source link

inert required #4

Closed MortalCatalyst closed 8 years ago

MortalCatalyst commented 8 years ago

Not sure you can do much about this now but I am following your hapi starter course, going well. You were using hapi 8.4 I beleive.

Anyway at time now any version that a person uses greater than 9 will need to use 'Inert' in their code to allow to serve a static file. example here https://www.npmjs.com/package/inert#examples This was from this github issue https://github.com/hapijs/hapi/issues/2682#issuecomment-130574238

which means this was the code in section 2 I needed to write

var Hapi = require('hapi');
var Inert = require('inert');

var server = new Hapi.Server();

server.connection({ port: 3000});

server.ext('onRequest', function(request, reply) {
  console.log('Request received: ' + request.path);
  reply.continue();
});

server.register(Inert, function () {});

server.route({
  path: '/',
  method: 'GET',
  handler: {
    file: 'templates/index.html'
  }
});

server.start(function() {
  console.log('Listening on ' + server.info.uri);
});
ryanmurakami commented 8 years ago

Thanks for the issue! You're totally right, there are some breaking changes in version 9. I've added a message to the front page of this repository to address it. My best suggestion for the course is to use version 8.8.1, so all the demo code will work perfectly. Your code above also works great.

Let me know if you find anything else.