Add hook normalization & finally hook (#34897)

This commit is contained in:
Evan Kennedy
2019-04-26 16:08:02 -07:00
committed by Pranav Senthilnathan
parent 03b4f06ce7
commit ab61661da8
2 changed files with 14 additions and 3 deletions
@@ -21,5 +21,15 @@ app.service('users').hooks({
context.statusCode = 200;
context.dispatch = { test: 'true' };
}
},
after: [
(context: HookContext) => {
context.statusCode = 200;
context.dispatch = { test: 'true' };
}
],
finally: (context: HookContext) => {
context.statusCode = 200;
context.dispatch = { test: 'true' };
}
});
+4 -3
View File
@@ -137,9 +137,10 @@ declare namespace feathers {
}
interface HooksObject {
before: Partial<HookMap>;
after: Partial<HookMap>;
error: Partial<HookMap>;
before: Partial<HookMap> | Hook | Hook[];
after: Partial<HookMap> | Hook | Hook[];
error: Partial<HookMap> | Hook | Hook[];
finally: Partial<HookMap> | Hook | Hook[];
}
// todo: figure out what to do: These methods don't actually need to be implemented, so they can be undefined at runtime. Yet making them optional gets cumbersome in strict mode.