Skip to content

Instantly share code, notes, and snippets.

@sgress454
Created September 19, 2014 20:25
Show Gist options
  • Save sgress454/e1413aa86d08ba2e9e24 to your computer and use it in GitHub Desktop.
Save sgress454/e1413aa86d08ba2e9e24 to your computer and use it in GitHub Desktop.
Reload a Sails API at runtime
// Reload controller middleware
sails.hooks.controllers.loadAndRegisterControllers(function() {
sails.once('hook:orm:reloaded', function() {
// Flush router
sails.router.flush();
// Reload blueprints
sails.hooks.blueprints.bindShadowRoutes();
return cb && cb();
});
// Reload ORM
sails.emit('hook:orm:reload');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment