Snake_case or camelCase in node.js
javascript, node.js
Solution
As Occam's razor principle says, the simplest solution is the best one.
If you have client's requirements on the one hand and node.js code style guides on the other hand. I would take the simplest solution satisfying the both. External API should be snake case and internally you can use camel case. If you stick to consistency you can use snake case everywhere, as I assume client's requirements have higher priority.
I would really avoid any additional layers for converting cases as it introduces additional complexity to the final solution, it can have additional errors, and it will require additional maintenance in the future.
Problem
So I have node.js application that exposes some API to clients and connects to some SQL database. First let introduce some premises: - Clients must use API with snake_case (keys in JSON object sent in request body are in snake_case). - Database column names are also snake_case. Problem is because javascript standard/practice is using camelCase which I would like to keep. So as I see there are 3 solutions: - Transform data from snake(API) to camel (application) to snake (database) on the fly as needed. This would introduced some new layers to system and all of it would be little complicated than other solutions. - Use snake_case in node.js app. But no matter if I use snake all other dependencies I am using will still be in camel which doesn't solve whole problem. - Mix snake_case and camelCase in node.js app. This is something I would like to avoid :) So what do you suggest? Mine favorite is first solutions but if you have some other smart ideas not mentioned here please feel free to tell.