问题
Based on this issue, I have nested controllers and blueprints are disabled. My issue is something like
api/Controllers : v1/UserController.js
routes.js
'POST /v1/user/register': 'v1/UserController.createUser'
Policies.js
'v1/UserController': {
'*': [ 'passport'],
createUser: ['ModelPolicy','AuditPolicy','reqBodyValidation']
If it is nested controller: while accessing the endpoint :
Output is something :
error: Sending 500 ("Server Error") response:
Error: Invalid route option, "model".
I don't know about any models named: `v1/user`
Appreciate to resolve.
回答1:
We actually did this in our project, and you can actually do this if you specify a string literal as the key for the controller in the JSON object like so:
'v1/UserController' : {
'*': [ 'passport'],
createUser: ['ModelPolicy','AuditPolicy','reqBodyValidation']
}
来源:https://stackoverflow.com/questions/33362577/api-versioning-in-sailsjs