Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upsetup service method not called in async plugin #67
Comments
|
|
|
One option would be to wait for configure to finish by making it async, i.e.: app.configure(function (done) {
setTimeout(done, 500);
})Or if backwards compatibility is a concern: app.configure(function (async) {
// if async isn't called, configure must be sync
var done = async();
setTimeout(done, 500);
})In my blueprints plugin I'm calling the |
|
I wouldn't use var app = require('feathers')();
app.use('/setup', {
get : function (id, params, callback) {
callback(null, {});
},
setup : function (app) {
console.log('setup');
}
});
setTimeout(function () {
app.use('/nosetup', {
get : function (id, params, callback) {
callback(null, {});
},
setup : function (app) {
console.log('no setup :(');
}
});
app.listen(8080);
}, 100);Because we can't know if the provider (REST, SocketIO, Primus - and potentially more in the future) might hook into |
|
Hmm, ok. That was the approach I took when developing a blueprints plugin. What'd be an alternative? The goal for my plugin was to generate services based on model definitions and hook them up to the application using the plugin architecture. You can have a look at the source code to check implementation details. Since I have opened this issue I changed from calling setup manually to providing a callback, so you can wait for the initialization to be finished. |
|
The more I'm thinking about it ... it should also be possible to mount another express application. Theoretically, I could implement the blueprints as a standalone feathers app and mount that, but I'm uncertain whether that's really necessary - maybe you can share your thoughts. |
|
The question is why you need to register services after starting the application. One option would be to override I will probably add an error for version 1.0 if you are trying to register a service on an already running application so that nobody runs into weird issues that could happen if you do. |
Removing the dry-run arg so the update script actually updates
Removing assigning token to params.query for sockets. Closes #65.
Removing assigning token to params.query for sockets. Closes #65.
|
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs. |
Even though the
setupmethod isn't called, the services work properly.