My project is getting larger and router.js is growing too. Is it possible to split it into several different route files? Each route file applies to a different controller.
Sails.js is a Node.js framework that allows you to build enterprise-ready, custom MVC ( model, view, controller ) application on-the-go. Sails.js has built-in features such as an API creator, and its socket integration in every route and database ORM makes it very useful and helps speed up development.
Sails allows you to explicitly route URLs in several different ways in your config/routes.js file. Every route configuration consists of an address and a target, for example: The route address indicates what URL should be matched in order to apply the handler and options defined by the target.
Like most web frameworks, Sails provides a router: a mechanism for mapping URLs to actions and views. Routes are rules that tell Sails what to do when faced with an incoming request. There are two main types of routes in Sails: custom (or "explicit") and automatic (or "implicit").
Furthermore, common security parameters such as CORS and CSRF are already included in Sails.js project. All you need to do is to enable them from respective files and your application is secured with the latest security standards.
In sails, you can put your routes in any file in config/
, as long as you export module.exports.routes
. So you can do something like this:
module.exports.routes = { };
_.defaults(sails.config.routes, {
// other routes
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With