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

Commit

Permalink
Added index.ts documentation for hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
ozziest committed Apr 8, 2024
1 parent ee15e3d commit 7fb16fc
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/learn/hooks-and-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,26 @@ Let's check out the following example;
- `All`: The action of data fetching all.
- `Show`: The action of fetching one item.

## `index.ts` file

As an alternative, you can use an `index.ts` file for each model that contains all of your hooks functions inside.

::: code-group

```ts [app/v1/Hooks/User/index.ts]
import { IContext } from "axe-api";

export const onBeforeInsert = async (context: IContext) => {
// add your custom logic in here
};

export const onAfterInsert = async (context: IContext) => {
// add your custom logic in here
};
```

:::

## HTTP Request-Response Cycle

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

0 comments on commit 7fb16fc

Please sign in to comment.