#Multi-Use Functions, Where to put them?

7 messages · Page 1 of 1 (latest)

broken sandal
#

I've got a couple of functions that are used for processing and validating the JWT token inside a cookie, checking the expiration date and throwing errors if need be.

Falling in line with the DRY method, where would be the best place to have these functions physically in the code?

I'm looking at modularity, DRY and ease of use internally.

warm ember
wicked swallow
#

Well you could have a utils/commons/helpers folder if it doesn't bother you. I try to avoid this as this always end up being a cryptic mess, why don't you put this file in your auth (or whatever you auth logic is) folder?

ripe garnet
#

Auth lib seems like a good place. Avoid thinks like generic utils at all costs, because as @wicked swallow said, it always becomes a dumpster for stuff you don't want where to put.

broken sandal
broken sandal
warm ember
#

yeah it depends on how you handle "helpers", imo you should keep all your auth stuff inside an auth context