krakenjs/kraken-js

Meddleware registered against kraken's module path, not specified "basedir" parameter.

thirtified opened this issue · 3 comments

The meddleware instance loaded by kraken is initialized against the kraken's directory (typically <app path>/node_modules/kraken-js/lib), not against the basedir path as stated in the documentation. Custom middleware module paths therefore have to be specified relative to the kraken module – even worse, the libdirectory within the module. A module path in the root directory of the app would therefore have to be specified as ../../../<module> (although ../../<module> also works because of require's swallowing of node_modules path components).

meddleware currently doesn't seem to support explicit basedir specification. Should be fairly easy to add this support, otherwise kraken would have to pre-process module paths appropriately to achieve the same result.

I think it would make a lot of sense to initialize meddleware in reference to the app's root directory, but right now it doesn't behave as documented.

Hi @thirtified it seems like the middlewares resolution paths are not meant to be specified as standalone values, but by using the path/resolve protocol resolver (shortstop) which are defaulted to the project root.

See: https://github.com/krakenjs/kraken-js#resolve

grawk commented

Agree that the docs may be somewhat misleading on this point but it seems like you should be able to handle any possible use cases with shortstop handlers. I.e. you shouldn't have to ever author any relative paths from the kraken lib directory. Can you provide any use cases where the shortstop handlers won't work?

grawk commented

Close due to inactivity.