dwyl / style-guide

:newspaper: dwyl's visual and coding style guide
GNU General Public License v2.0
24 stars 13 forks source link

Handler Naming #6

Closed rjmk closed 7 years ago

rjmk commented 9 years ago

Putting '_handler' at the end of all your handler files gets pretty redundant and unnecessarily lengthy. On the other hand, calling your riot or redis handler something like 'riot' or 'redis' is pretty confusing. What should we do??? :question:

nelsonic commented 9 years ago

Provided your handlers are in a /handlers directory it should be sufficiently clarifying.

rjmk commented 9 years ago

Cool. What about the name of the variable when required in? For example in a file where riot is never required directly, can we have var riot = require('./handlers/riot')?

nelsonic commented 9 years ago

how are you using it? can you paste a link to the commit/file/line ?

rjmk commented 9 years ago

Here is the sort of place I would consider using it: https://github.com/dwyl/hapi-socketio-redis-riot-chat-example/blob/095e4f6c3a951fb9e7ed96bb08fdaa13dc4fc0c1/server.js#L3

nelsonic commented 9 years ago

in that example I would just:

{ method: 'GET', path: '/', handler: require('./lib/riot_handler.js') },

No need to assign the handler to a variable before using it.

rjmk commented 9 years ago

Cool :+1:

rjmk commented 7 years ago

This is issue is being automatically closed as it's more than a year old. Please feel free to reopen it if it's still relevant to your project.