@@ -16,15 +16,15 @@ head:
16
16
17
17
# Life Cycle
18
18
19
- Also knows as middleware with name in Express or Hook in Fastify.
19
+ Also known as middleware with name in Express or Hook in Fastify.
20
20
21
21
Imagine we want to return a text of HTML.
22
22
23
23
We need to set ** "Content-Type"** headers as ** "text/html"** to for browser to render HTML.
24
24
25
- Explicitly specify that response is HTML could be repetitive if there are a lot of handlers, says ~ 200 endpoints.
25
+ Explicitly specifying that response is HTML could be repetitive if there are a lot of handlers, says ~ 200 endpoints.
26
26
27
- We can see a duplicated code for just to specify that response is HTML.
27
+ We can see a duplicated code for just specifying that response is HTML.
28
28
29
29
But what if after we sent a response, we could detect if a response is an HTML string then append headers automatically?
30
30
@@ -46,7 +46,7 @@ Most of the events you are going to use are highlighted in the blue area but to
46
46
Elysia does the following for every request:
47
47
48
48
1 . ** Request**
49
- - Notify new event is received, providing only the most minimal context to reduce overhead
49
+ - Notify when a new event is received, providing only the most minimal context to reduce overhead
50
50
- Best for:
51
51
- Caching
52
52
- Analytics
@@ -87,15 +87,15 @@ These events are designed to help you decouple code into smaller reusable pieces
87
87
88
88
## Hook
89
89
90
- We refer to each function that intercepts the life cycle event as ** "hook"** , as the function hook into the lifecycle event.
90
+ We refer to each function that intercepts the life cycle event as ** "hook"** , as the function hooks into the lifecycle event.
91
91
92
92
Hooks can be categorized into 2 types:
93
93
94
94
1 . Local Hook: Execute on a specific route
95
95
2 . Interceptor Hook: Execute on every route
96
96
97
97
::: tip
98
- The hook will accept the same Context as a handler, you can imagine you adding a route handler but at a specific point.
98
+ The hook will accept the same Context as a handler, you can imagine adding a route handler but at a specific point.
99
99
:::
100
100
101
101
## Local Hook
@@ -187,4 +187,4 @@ Console should log as the following:
187
187
1
188
188
2
189
189
3
190
- ```
190
+ ```
0 commit comments