Try to fit the function in one page by breaking it and making functions for each unit of work. If your function is long see if you can name any block of code by something or not. Then make a function with that name
If the parameter count is over 2/3 then pass them as objects
Try to avoid nested if else by returning early using inverted logic:
Services
Services will call Repositories for data access and manipulations
Try to make services atomic. Of course there will be one big orchestrator service that will use lots of service to do its work.
A service is responsible for implementing the business logic and application specific functionality.
It often acts as an intermediary between the controller and the data access layer (repository).
Try to look for related work and group them into one service.
Controller
Remember controller is the one who “controls” things. It will take in request and send response using the services.
Logging
Put logging before each action atleast, doing it after the action might be useful too.
Use our logger util from “logger.js” file in “helpers” folder
Error Handling
coming
Utilities
If you have large/complex match query then put it inside helpers/queryBuilder.js folder to encapsulate the logic for maintainability and readability.
All the associated utilities will go in one file (helpers.js folder) . Example:
Utilities that work with array will go to array.js
To send notification, modify the code as below:
Performance
Promise.all: Use promise.all() properly to run tasks in parallel.
Git flow
Label
Put “Review Required” label when you create a PR
Once everybody has reviewed the code the label will be “Ready”
local → dev
dev
feature
None
Want to print your doc? This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (