Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
FeathersJS - Demo of services picking up each others hooks
module.exports = function(app) {
class BeepBoop {
async update(id, data, params) {
console.log("BeepBoop", id, params);
// passing params here will also pass the route.id
await app.service("zap").update("456", {}, params);
return Promise.resolve();
}
}
app.use("beep/:id/boop", new BeepBoop()).hooks({
before: {
update: context => {
if (context.params.route && context.params.route.id) {
context.id = context.params.route.id;
}
}
}
});
class Zap {
update(id, data, params) {
console.log("Zap", id);
return Promise.resolve();
}
}
app.use("zap", new Zap());
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment