-
-
Notifications
You must be signed in to change notification settings - Fork 751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setup service method not called in async plugin #67
Comments
setup
service method not called in async plugin
|
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
* chore(package): update sinon to version 6.0.0 * Update Travis install script
Removing assigning token to params.query for sockets. Closes #65.
* chore(package): update sinon to version 6.0.0 * Update Travis install script
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
setup
method isn't called, the services work properly.The text was updated successfully, but these errors were encountered: