hapijs / glue

Server composer for hapi.js
Other
245 stars 62 forks source link

Inconsistent plugin load order #19

Closed jlines closed 9 years ago

jlines commented 9 years ago

I am loading my manifest using glue. The plugins section of manifest looks like this

plugins: { 'hapi-auth-jwt':{}, './server/api/index': {} }

My api/index calls server.auth.strategy('token', 'jwt' ....

This call fails sometimes with the message Authentication strategy token uses unknown scheme: jwt

It seems that the load order of the plugins are not guaranteed which is causing my problem. Is there a recommended way to address this problem?

Marsup commented 9 years ago

JSON keys order have never been deterministic, use dependencies for that.

csrl commented 9 years ago

If the manifest's 'plugins' field learned to expect an array, plugin load order could be made deterministic. However, if you are writing a plugin with a known dependency, then using the Server.after() and Server.dependency() support is certainly the proper approach, such that users of your plugin do not need to concern themselves with load order.

lock[bot] commented 4 years ago

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.