Disable custom hook in sails

I use sails in a project hosted on Heroku. I have a web process with a sails web server and a workflow using the same models as those used by the web server.

To make it possible, I have another way to start each process using the same code:

  • standard way app.js
  • the worker.js file, which runs the same sail application, only the orm application and the service are activated.

However, I added some user hooks to the api / hooks folder, which I do not want the worker to start. Is there an easy way to disable these hooks? I tried to sail up with {"userhookname": false} passed to config, but it doesn't seem to work.

thank

+4
source share
1 answer

Sails.js does not currently support disabling individual user hooks in the same way as main hooks, although it certainly makes sense to implement this function. In the meantime, the easiest thing is to simply implement the switch in the hook itself. In defaultsspecify the key active, which by default is equal true, and then in initialize, before continuing, make sure that activethere is true. See sails-hook-autoreload for an example .

+3
source

All Articles