3

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.

Ayyappa A
  • 657
  • 3
  • 8
  • 24

1 Answers1

2

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']
}
Russell Santos
  • 411
  • 2
  • 8
  • Hi Russell, Thanks for your update. Here problem is that, I want to keep models also nested files inside model directory. In controller, i am trying to give model something like this _config: { Model : 'v1/User' }, – Ayyappa A Oct 27 '15 at 10:25
  • Sorry, can you clarify what exactly you want to do with the model? I'm afraid I am not able to understand what you want to happen. – Russell Santos Oct 27 '15 at 10:27
  • Hi Russell, Apology, Typo Error... I am trying to access nested model in nested controllers, Stucked at controller on how to access nested models inside controller i have given _config: { Model : 'v1/User' }, but unable to access user model. – Ayyappa A Oct 27 '15 at 10:30
  • I don't think that's actually possible in Sails at the moment. I would suggest that you do versioning in the name itself: eg V1_User, V2_User, etc. – Russell Santos Oct 29 '15 at 04:05
  • Russell Please refer this once... http://stackoverflow.com/questions/33367549/nested-models-and-controllers-in-sails-are-not-working-policies/33369985#33369985 – Ayyappa A Oct 29 '15 at 04:34