How can I reset my controller in Koa?

When a request comes in, I want to reload the controller to improve my debugging speed.

When I make changes to the controller method, I have to reboot the entire server, which takes 4-5 seconds.

I also use koa-mount

to configure various endpoints, so the solution should be compatible with koa-mount

.

+3


source to share


1 answer


I was able to do this by fixing koa-mount

it by allowing a module path string to be passed and requiring a call on every request.

In dev mode, we will invalidate the cached modules that we want to reload.



The prod call require

in our patched koa-mount

will use the cached module.

See it here: https://gist.github.com/vjpr/b13bd1bc2f636bb28cd8

+1


source







All Articles