Being fairly new to NodeJS I wonder what would be the best approach for the following 'problem'.
My main application accepts variables including a device_type
and a payload
. The way this payload
needs to be decrypted depends on the device_type
.
To avoid using a big case/switch or if-clause and to be able to just drop in a new device when needed; I'm looking for a more object oriented approach.
In PHP I would create a class for each device and 'load' them accordingly from the correct namespace with a decorator. Each class would have a decrypt() method (enforced by using contract)
How would I accomplish a same structure in nodejs?