Thursday 25 October 2018

IoC or similar in Node

I know this comes up a lot, but hear me out.I'm playing with a new project in node, and to start off I'm doing healthchecks. (It's a nice way to test all parts of the system can interact, and proves deployment and automated tests work)I've got a handler for this already, and it works fine. But I want to have a reasonable coverage from the checks. In particular:Local system health (memory, disk space, etc)PostgresRedisGoogle API - if configuredOthers in the futureNow, writing code to test all of these is relatively easy. And writing a handler that iterates over them all is easy. But it's the wiring them up I get stuck on.The ways that come to mind are:Handler imports all of the checks and depends on them directly. This is a testing nightmare.Handler is somehow constructed by providing the list of checks. How?I can obviously achieve the second option by having a function somewhere that wires everything up, but then that function depends on everything. And that's horrible.So, what do people normally do to achieve this?

Submitted October 25, 2018 at 09:04PM by sazzer

No comments:

Post a Comment