I want to make a watchdog (using setInterval) that checks in the background some checks during a controller's endpoint (using an interceptor for initializing and clearing the interval function).
If some of the checks are false, I want to end the handle of the endpoint. If I throw an error, it gets to UnhandledPromiseRejection. If I catch it there, the endpoint continues, and if not - the application stops.
Is there a way I can stop the endpoint through background checks?