- I'd recommend sticking with es6 syntax (no async-await).
- Always consider throttling
- Try to make scripts atomically process data that fits the lambda time allotment
- Connections [DB] should be handled at the top most points and always wrapped in a function
- Scripts should always exit when done doing atomic work (dangling connections problem)
- Logging should be using a single/configurable handler (verbosity, cli, parsable)
- Logging should be done where you see neccesary but at a minimum at the tail end + top most point of the process for feedback on the atomic data processed (
then
andcatch
should be directly visible in the entry script) .then(fn)
- fn should either be stupidly simple or be extractable to the point of being able to be unit tested. The name should also be painfully obvious (reference)- The main logic should have multiple entry scripts for things like cli, direct node invocation, and lambda calls
Newer ES versions allow for a slew of coding styles. I'd recommend automating prettier in the commit flow so that the style can be any way you want but the outcome will follow a strict opinion.
- If your arrow function is more than 1 line, don't use syntax to make it still a 1 line body
(list, n = 3) =>
list
.map(u => u.first_name)
.slice(0, n)
.join(", ") +
(list.length > n
? ", and " + (list.length - n) + " more..."
: "")
- You should be explicit about what properties your elements need. Things like redux only do shallow checking. Also testing a component should be easier and more obvious with explicit props.