Atlantis-Software / sails-hook-orm-offshore

Implements support for Offshore ORM in Sails.
https://github.com/Atlantis-Software/Offshore
8 stars 1 forks source link

Blueprints are not working #2

Closed bonanzakrak closed 8 years ago

bonanzakrak commented 8 years ago

I just tested that and have noticed that Blueprint API is not working with this hook. Is there any possibility to make it work ?

atiertant commented 8 years ago

@bonanzakrak for sure, could you give me more explaination? could you post the full error log or write a simple test ?

pdavid0 commented 8 years ago

I have the same problem but I don't have any error message.

{
  "hooks": {
    "orm": false,
    "pubsub": false
  }
}
module.exports.blueprints = {
   ...
    prefix: '/v1'
   ...
};

/v1/myModel/1 -> 404

bonanzakrak commented 8 years ago

Same @pdavid0 said. When you thy to execute any blueprint method from method they are not present. All models are ignored by router. Its easy to check.

With Waterline:

  1. Switch to loglevel: 'silly'
  2. Start sails: 'sails console'

first lines from model/controller User log: silly: Binding RESTful blueprint/shadow routes for model+controller: user silly: Binding route :: get /user (POLICY: texts)

With Offshore: there is no RESTful, only controller actions. All actions that should be available from model like GET, POST return 404.

first lines from model/controller User log: silly: Binding action (myAction) blueprint/shadow route for controller: user silly: Binding route :: /user/myAction/:id? (POLICY: texts)

It may be something with router, that is ignoring Offshore ORM. But would be nice to find a solution how to fix it.

Will try to find a moment and create a project that will illustrate the issue with tests.

atiertant commented 8 years ago

@bonanzakrak i'll take a look too but i would love add travis test

bonanzakrak commented 8 years ago

I think i found the issue. Its inside Blueprint hook itself. Its checking if ORM hook is enabled. Because Offshore hook is disabling Waterline it will not work that way. Here is mine solution written in 15 minutes not well tested yet: sails-hook-blueprints-offshore

atiertant commented 8 years ago

@bonanzakrak great work ! what did you changed and how do you think it could be integrate in this hook?

bonanzakrak commented 8 years ago

@atiertant i changed hook name

sails.hooks.orm

to

sails.hooks['orm-offshore']

and event listener

eventsToWaitFor.push('hook:orm:loaded');

to

eventsToWaitFor.push('hook:orm-offshore:loaded');

also added

var offshore = require('offshore');
atiertant commented 8 years ago

@bonanzakrak thanks for your help, the problem with this solution is to maintain code...but the benefit is that we could integrate deep in blueprints...

atiertant commented 8 years ago

@bonanzakrak i don't think var offshore = require('offshore'); is required, so package.json needn't offshore as dependency

bonanzakrak commented 8 years ago

@atiertant i removed that dependency. I don't know why it crashed without it before. Now it works without it.

atiertant commented 8 years ago

the hook sails-hook-blueprints-offshore is now packaged in npm. thanks @bonanzakrak