Hi Im new to node & sails and the same time doing some standards in my codes. In sails.js I currently have this, for example below
api/
controllers/
TestController.js
services/
TestServices.js
Mostly I can access the view with using only this URL format:
http://localhost/test/
http://localhost/test/<action>
If I add some prefixes to my filename, it will become like this:
api/
controllers/
PrtestController.js
services/
PrtestServices.js
URL by right should be accessible via:
http://localhost/prtest/
http://localhost/prtest/<action>
Questions:
1) if I add prefixes to all my controller & services filenames, is it possible to access the url by:
http://localhost/test/
http://localhost/test/<action>
without adding prefix?
I was thinking of configuring config/routes.js in order to achieve this by editing something like this:
'/test': {
controller: 'PrtestController',
action: '<action>'
},
'/test/*': {
controller: 'PrtestController'
}
Honestly, I haven't tried it yet (it's just an idea before I make major changes in my codes else I might messed it up)
2) Is it possible to have this in sails.js
PrtestController.js > prTestController.js
Thanks in advance!
EDITED QUESTION
Btw I'm using default sails config for controllers having values of:
blueprints: {
actions: true,
rest: true,
shortcuts: true,
prefix: ''
...
} Example: (my routes.js will be looked like this)
'/test' : 'prTestController',
'/test/action2' : 'prTestController:action2',
'/test/action3' : 'prTestController:action3',
'/test/action4' : 'prTestController:action4',
'/test/action5' : 'prTestController:action5',
'/test/action6' : 'prTestController:action6',
'/test/action7' : 'prTestController:action7',
'/test/action8' : 'prTestController:action8',
'/test/action9' : 'prTestController:action9'
Is it possible for routes that if the url is having /test or /test/any_action will automatically used controller prTestController or prTestController:any_action, respectively?
For #2, yup that's what I mean.
Thanks much!