hapijs-birds-api icon indicating copy to clipboard operation
hapijs-birds-api copied to clipboard

Few nits (I hope that's ok?)

Open AdriVanHoudt opened this issue 7 years ago • 0 comments

  • Why not handle error more nicely on startup? If hapi returns an error there is no use in trying to continue to boot the server (in 99% of the cases) you will be uncertain of the state your server/hapi will be in. An easy suggestion is to just check for an error and throw if it is there. See https://github.com/labsvisual/hapijs-birds-api/blob/fbd10df6885d1bb713c29d76ff56d0a3746274b5/src/server.js#L12 and https://github.com/labsvisual/hapijs-birds-api/blob/fbd10df6885d1bb713c29d76ff56d0a3746274b5/src/server.js#L38

  • Secondly I think it is cleaner to only call .start when you are sure that everything else (hapi wise) is set up. What I mean by that is simply put the start call in the callback of the register call :D See https://github.com/labsvisual/hapijs-birds-api/blob/fbd10df6885d1bb713c29d76ff56d0a3746274b5/src/server.js#L36

  • Why not just reply err here https://github.com/labsvisual/hapijs-birds-api/blob/master/src/routes.js#L39 ? It will help figure out what is going wrong.

AdriVanHoudt avatar Jan 19 '17 21:01 AdriVanHoudt