ccarruitero / makemehapi

Self guided workshops to teach you about hapi.
https://www.npmjs.com/package/makemehapi
Other
480 stars 107 forks source link

Handling: no absolute path needed #149

Closed marcopiraccini closed 4 years ago

marcopiraccini commented 9 years ago

The description says:

Be careful: in practice, you’ll need to provide an absolute path to an index.html file in your program’s directory. To achieve this, you’ll probably need the path core module, its join() function, and the __dirname global variable.

However the solution is ok also with:

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

So, it seems that handler.file can be also relative. Should we spceify that in the exercise description?

JafarAkhondali commented 7 years ago

As noted on Hapijs style guide

Always use relative paths But in makemehapi helper says to use absolute path many times. Is it ok?

ccarruitero commented 4 years ago

Hi @marcopiraccini, thanks for use the workshop.

The solution have a relative path in the route because has set the files to be relative to the directory in the server routes options https://github.com/ccarruitero/makemehapi/blob/master/exercises/handling/solution/solution.js#L10

I updated the problem to mention that in https://github.com/ccarruitero/makemehapi/commit/f8bae05cb69c11fb255ffb07a848fb3890e934c4#diff-79fe0e5db0e9285a2b8095a63e7c36d6

Feel free to open other issue if you have any question.