diff options
author | 2024-02-10 18:19:14 -0700 | |
---|---|---|
committer | 2024-02-13 06:59:44 +0530 | |
commit | 7584d2d7a7110aef0331ebfa178b2295842c59fa (patch) | |
tree | 900cd71237e6231b57936fcce77ff229cd459041 /types/events.ts | |
parent | upgrade recipes submodule (diff) | |
download | ferdium-server-7584d2d7a7110aef0331ebfa178b2295842c59fa.tar.gz ferdium-server-7584d2d7a7110aef0331ebfa178b2295842c59fa.tar.zst ferdium-server-7584d2d7a7110aef0331ebfa178b2295842c59fa.zip |
refactor: project maintenance
- work in progress
Diffstat (limited to 'types/events.ts')
-rw-r--r-- | types/events.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/types/events.ts b/types/events.ts new file mode 100644 index 0000000..91be5b4 --- /dev/null +++ b/types/events.ts | |||
@@ -0,0 +1,33 @@ | |||
1 | /** | ||
2 | * Contract source: https://git.io/JfefG | ||
3 | * | ||
4 | * Feel free to let us know via PR, if you find something broken in this contract | ||
5 | * file. | ||
6 | */ | ||
7 | |||
8 | import User from '#app/Models/User' | ||
9 | |||
10 | declare module '@ioc:Adonis/Core/Event' { | ||
11 | /* | ||
12 | |-------------------------------------------------------------------------- | ||
13 | | Define typed events | ||
14 | |-------------------------------------------------------------------------- | ||
15 | | | ||
16 | | You can define types for events inside the following interface and | ||
17 | | AdonisJS will make sure that all listeners and emit calls adheres | ||
18 | | to the defined types. | ||
19 | | | ||
20 | | For example: | ||
21 | | | ||
22 | | interface EventsList { | ||
23 | | 'new:user': UserModel | ||
24 | | } | ||
25 | | | ||
26 | | Now calling `Event.emit('new:user')` will statically ensure that passed value is | ||
27 | | an instance of the the UserModel only. | ||
28 | | | ||
29 | */ | ||
30 | interface EventsList { | ||
31 | 'forgot:password': { user: User; token: string } | ||
32 | } | ||
33 | } | ||