Closed weyj4 closed 8 years ago
2) Get this sorted out and start serving a dist/ directory.
@weyj4 can you elaborate? this is re trailsjs/trailpack-hapi#3
This is specifically what I'm trying to implement: https://github.com/hapijs/inert#static-file-server
It seems to me that we'd want this to go in config/{something}. But any handler in config/ gets split with the expectation that it's of the form Controller.HandlerFunction inside api/controllers. I just want to pass an object directly into config for this.
@lynnaloo @ryanwilliamquinn do either of y'all have input? Linda and I talked about this some this morning.
By the spec, Hapi handlers can be both an object or a function. Serving a static directory is just one example of that so it doesn't seem right to decorate the handlers before adding the route.
In the Hapi source code, I believe that if the handler is an object, then it gets decorated to look like the typical function format. If the router can't accept an object, then maybe the solution is to add a similar decorator here?
@tjwebb we can close this if you want. at any rate it's mostly hapi-specific.
Now it's fix we also allow object, I'm closing this :)
The relevant code is in the repo at lib/xfmr.js:61+.
Are we sure we want to limit handlers in this way? According to the Hapi docs, "Alternatively, handler can be assigned an object with a single key using the name of a registered handler type and value with the options passed to the registered handler".
This becomes necessary for instance when using the "inert" package (https://github.com/hapijs/inert) to serve a static directory (http://hapijs.com/tutorials/serving-files).