You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/blog/elysia-02.md
+34-34Lines changed: 34 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,16 +38,17 @@ head:
38
38
date="29 Jan 2023"
39
39
>
40
40
41
-
「[Blessing](https://youtu.be/3eytpBOkOFA)」brings more improvement, mainly on TypeScript performance, type-inference, and better auto-completion and some new features to reduce boilerplate.
41
+
42
+
「[Blessing](https://youtu.be/3eytpBOkOFA)」brings many improvements, mainly in TypeScript performance, type-inference, better auto-completion, and new features to reduce boilerplate.
42
43
43
44
Named after YOASOBI's song「祝福」, an opening for Witch from "Mobile Suit Gundam: The Witch from Mercury".
44
45
45
46
## Defers / Lazy Loading Module
46
-
With Elysia 0.2 now add support for the lazy loading module and async plugin.
47
+
Elysia 0.2 now adds support for lazy loading modules and async plugins.
47
48
48
-
This made it possible to defer plugin registration and incrementally apply after the Elysia server is started to achieve the fastest possible start-up time in Serverless/Edge environments.
49
+
This makes it possible to defer plugin registration and incrementally apply plugins after the Elysia server has started, achieving the fastest possible start-up time in Serverless/Edge environments.
49
50
50
-
To create defers module, simply mark the plugin as async:
51
+
To create a deferred module, simply mark the plugin as async:
This will register the module after the import is finished making the module lazy-load.
70
71
71
-
Defers Plugin and lazy loading module will have all type-inference available right out of the box.
72
-
72
+
Deferred plugins and lazy loading modules will have full type-inference available right out of the box.
73
73
74
74
## Reference Model
75
-
Now Elysia can memorize schema and reference the schema directly in Schema fields, without creating an import file via `Elysia.setModel`
75
+
Now Elysia can memorize schemas and reference them directly in Schema fields, without creating an import file via `Elysia.setModel`.
76
76
77
-
This list of schema available, brings auto-completion, complete type-inference, and validation as you expected from inline schema.
77
+
This list of available schemas brings auto-completion, complete type-inference, and validation as you would expect from inline schemas.
78
78
79
79
To use a reference model, first, register the model with `setModel`, then write a model name to reference a model in `schema`
80
80
```typescript
@@ -93,34 +93,34 @@ const app = new Elysia()
93
93
})
94
94
```
95
95
96
-
This will bring auto-completion of known models.
96
+
This will provide auto-completion of known models.
97
97
<imgwidth="1624"alt="Screenshot 2566-01-23 at 13 24 28"src="https://user-images.githubusercontent.com/35027979/213980696-8f20a934-c500-4f97-884c-ff2dd2efadfe.png">
98
98
99
-
And type reference stopping you from accidentally returning invalid type.
99
+
And type references prevent you from accidentally returning an invalid type.
100
100
<imgwidth="1624"alt="Screenshot 2566-01-23 at 13 26 00"src="https://user-images.githubusercontent.com/35027979/213980738-0e99cb25-a50f-4888-8879-f00d4ad04363.png">
101
101
102
-
Using `@elysiajs/swagger` will also create a separate `Model` section for listing available models.
102
+
Using `@elysiajs/swagger` will also create a separate `Model` section to list available models.
103
103
<imgwidth="1624"alt="Screenshot 2566-01-23 at 13 23 41"src="https://user-images.githubusercontent.com/35027979/213980936-5857e30b-fd4b-4fc3-8aff-fdb9054980d3.png">
104
104
105
-
Reference also handles validation as you expected.
105
+
References also handle validation as you would expect.
106
106
107
-
In short, it's as same as inline schema but now you only need to type the name of the schema to handle validation and typing instead of a long list of imports.
107
+
In short, it's the same as using inline schemas, but now you only need to type the name of the schema to handle validation and typing, instead of a long list of imports.
108
108
109
109
## OpenAPI Detail field
110
-
Introducing new field `schema.detail` for customizing detail for the route following the standard of OpenAPI Schema V2 with auto-completion.
110
+
Introducing a new field,`schema.detail`, for customizing details for the route, following the standard of OpenAPI Schema V2 with auto-completion.
111
111
112
112
<imgwidth="1624"alt="Screenshot 2566-01-23 at 13 54 11"src="https://user-images.githubusercontent.com/35027979/213981321-5717e514-aa4b-492a-b45a-9e69099dc8a8.png">
113
113
114
-
This allows you to write better documentation and fully editable Swagger as you want:
114
+
This allows you to write better documentation and have a fully editable Swagger as you want:
115
115
<imgwidth="1624"alt="Screenshot 2566-01-23 at 13 23 41"src="https://user-images.githubusercontent.com/35027979/213981545-46efc6cc-34bc-4db2-86ed-530d27d7ba97.png">
116
116
117
117
## Union Type
118
-
The previous version of Elysia sometime has a problem with distinct Union types, as Elysia tries to catch the response to create a full type reference for Eden.
118
+
The previous version of Elysia sometimes had problems with distinct Union types, as Elysia tried to catch the response to create a full type reference for Eden.
119
119
120
-
Results in invalidation of possible types,
120
+
This resulted in invalidation of possible types.
121
121
122
122
## Union Response
123
-
Made possible by Union Type, now returning multiple response status for `schema` now available using `schema.response[statusCode]`
123
+
Made possible by Union Type, returning multiple response statuses for `schema`is now available using `schema.response[statusCode]`.
124
124
125
125
```typescript
126
126
app
@@ -148,43 +148,43 @@ app
148
148
)
149
149
```
150
150
151
-
Elysia will try to validate all schema in `response` allowing one of the types to be returned.
151
+
Elysia will try to validate all schemas in `response`, allowing one of the types to be returned.
152
152
153
-
Return types are also supported report in Swagger's response.
153
+
Return types are also supported and reported in Swagger's response.
154
154
155
155
## Faster Type Inference
156
-
As Elysia 0.1 explore the possibility of using type inference for improving better Developer Experience, we found that sometimes it takes a long time to update type inference because of heavy type inference and in-efficient custom generic.
156
+
As Elysia 0.1 explored the possibility of using type inference to improve Developer Experience, we found that sometimes it took a long time to update type inference because of heavy type inference and inefficient custom generics.
157
157
158
-
With Elysia 0.2now optimized for faster type-inference, preventing duplication of heavy type unwrap, results in better performance for updating type and inference.
158
+
With Elysia 0.2, type inference is now optimized for speed, preventing duplication of heavy type unwrapping, resulting in better performance for updating types and inference.
159
159
160
160
## Ecosystem
161
-
With Elysia 0.2 enabling async plugin and deferred module many new plugins that isn't possible before became reality.
161
+
With Elysia 0.2 enabling async plugins and deferred modules, many new plugins that weren't possible before have become a reality.
162
162
163
-
Like:
164
-
- Elysia Static plugin with the non-blocking capability
163
+
For example:
164
+
- Elysia Static plugin with non-blocking capability
165
165
- Eden with union-type inference for multiple responses
166
166
- New Elysia Apollo Plugin for Elysia
167
167
168
-
### Notable Improvement:
169
-
-`onRequest` and `onParse`now can access `PreContext`
168
+
### Notable Improvements:
169
+
-`onRequest` and `onParse` can now access `PreContext`
170
170
- Support `application/x-www-form-urlencoded` by default
171
-
-body parser now parse`content-type` with extra attribute eg.`application/json;charset=utf-8`
172
-
- Decode URI parameter path parameter
171
+
-Body parser now parses`content-type` with extra attributes, e.g.,`application/json;charset=utf-8`
172
+
- Decode URI path parameters
173
173
- Eden now reports an error if Elysia is not installed
174
-
- Skip declaration of existing model and decorators
174
+
- Skip declaration of existing models and decorators
175
175
176
176
### Breaking Changes:
177
177
-`onParse` now accepts `(context: PreContext, contentType: string)` instead of `(request: Request, contentType: string)`
178
178
- To migrate, add `.request` to context to access `Request`
179
179
180
180
### Afterward
181
-
Thank you for supporting Elysia and being interested in this project.
181
+
Thank you for supporting Elysia and for your interest in this project.
182
182
183
-
This release brings better DX and hopefully all you need to write great software with Bun.
183
+
This release brings better DX and hopefully everything you need to write great software with Bun.
184
184
185
-
Now we have [Discord server](https://discord.gg/eaFJ2KDJck) where you can ask any questions about Elysia or just hang out and chill around is also welcome.
185
+
We now have a [Discord server](https://discord.gg/eaFJ2KDJck) where you can ask any questions about Elysia or just hang out and chill—everyone is welcome.
186
186
187
-
With the wonderful tools, we are happy to see what wonderful software you will build.
187
+
With these wonderful tools, we are excited to see what amazing software you will build.
0 commit comments