Skip to content
This repository was archived by the owner on Sep 1, 2024. It is now read-only.

Commit 7fb16fc

Browse files
committed
Added index.ts documentation for hooks
1 parent ee15e3d commit 7fb16fc

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/learn/hooks-and-events.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,26 @@ Let's check out the following example;
128128
- `All`: The action of data fetching all.
129129
- `Show`: The action of fetching one item.
130130

131+
## `index.ts` file
132+
133+
As an alternative, you can use an `index.ts` file for each model that contains all of your hooks functions inside.
134+
135+
::: code-group
136+
137+
```ts [app/v1/Hooks/User/index.ts]
138+
import { IContext } from "axe-api";
139+
140+
export const onBeforeInsert = async (context: IContext) => {
141+
// add your custom logic in here
142+
};
143+
144+
export const onAfterInsert = async (context: IContext) => {
145+
// add your custom logic in here
146+
};
147+
```
148+
149+
:::
150+
131151
## HTTP Request-Response Cycle
132152

133153
Hook and event functions would be executed after the middlewares and the before serializer.

0 commit comments

Comments
 (0)