HEY:
Work in progress so considere this more like a brain dump than battle-tested knowledge (although the ideas do come from the trenches).
Project layout
Layout
src/
| entry.js
|- config/
|- models/
|- services/
Dependency injection
Wrap the actual logic with a layer taking the DB service (instead of importing a client). It makes the code easier to test (mocking), less tied in implicit dependencies.
exort default (db) => {
movies.userInfo = (usernamce, cb) => {
db.query( /* … */ )
}
}
From The perfect architecture flow
#coding#design#tips