Wrapping service methods with middlewares
New localMethod
hook in middlewares which wraps the service methods.
Example
// my.middleware.js
module.exports = {
name: "MyMiddleware",
localMethod(next, method) {
return (...args) => {
console.log(`The '${method.name}' method is called in '${method.service.fullName}' service.`, args);
return handler(...args);
}
}
}
Schema for service methods
Similar for action schema, you can define service methods with schema. It can be useful when middleware wraps service methods.
Example for new method schema
// posts.service.js
module.exports = {
name: "posts",
methods: {
list: {
async handler(count) {
// Do something
return posts;
}
}
}
};