I have API with Sails.js and I want to wrap all my routes in v1
. Is it possible?
Here is what I tried, but it doesn't work.
routes.js
'use strict';
module.exports.routes = {
'/v1': { //
'get /cron': 'CronController.start' // THIS DOES NOT WORK
}, //
'get /cron': 'CronController.start' // this works
};
Based on my knowledge of Sails the only way to wrap all of your routes in /v1
is to first ensure the actions
boolean in config/blueprints.js
is set to true
(it is by default), and then further down in that file set the prefix
string to "/v1"
. Here is the documentation detailing this config.
Note that having the actions
boolean set to true
causes Sails to generate GET, POST, PUT, and DELETE routes for the action, make sure to use policies to ensure no unsafe logic is exposed in this way.
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