Skip to content

Commit 22d54b4

Browse files
committed
📘 doc: grammar
1 parent 7d233df commit 22d54b4

File tree

4 files changed

+20
-22
lines changed

4 files changed

+20
-22
lines changed

docs/blog/elysia-07.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ Reactive Cookie take a more modern approach like signal to handle cookie with an
115115
There's no `getCookie`, `setCookie`, everything is just a cookie object.
116116

117117
When you want to use cookie, you just extract the name get/set its value like:
118-
```ts
118+
```typescript
119119
app.get('/', ({ cookie: { name } }) => {
120120
// Get
121121
name.value
@@ -134,7 +134,7 @@ With the merge of cookie into the core of Elysia, we introduce a new **Cookie Sc
134134

135135
This is useful when you have to strictly validate cookie session or want to have a strict type or type inference for handling cookie.
136136

137-
```ts
137+
```typescript
138138
app.get('/', ({ cookie: { name } }) => {
139139
// Set
140140
name.value = {
@@ -161,7 +161,7 @@ Cookie signature is a cryptographic hash appended to a cookie's value, generated
161161
This make sure that the cookie value is not modified by malicious actor, helps in verifying the authenticity and integrity of the cookie data.
162162

163163
To handle cookie signature in Elysia, it's a simple as providing a `secert` and `sign` property:
164-
```ts
164+
```typescript
165165
new Elysia({
166166
cookie: {
167167
secret: 'Fischl von Luftschloss Narfidort'
@@ -189,7 +189,7 @@ By provide a cookie secret, and `sign` property to indicate which cookie should
189189
Elysia then sign and unsign cookie value automatically, eliminate the need of **sign** / **unsign** function manually.
190190

191191
Elysia handle Cookie's secret rotation automatically, so if you have to migrate to a new cookie secret, you can just append the secret, and Elysia will use the first value to sign a new cookie, while trying to unsign cookie with the rest of the secret if match.
192-
```ts
192+
```typescript
193193
new Elysia({
194194
cookie: {
195195
secret: ['Vengeance will be mine', 'Fischl von Luftschloss Narfidort']
@@ -207,7 +207,7 @@ This brings new exciting feature like support for TypeBox's `Decode` in Elysia n
207207
Previously, a custom type like `Numeric` require a dynamic code injection to convert numeric string to number, but with the use of TypeBox's decode, we are allow to define a custom function to encode and decode the value of a type automatically.
208208

209209
Allowing us to simplify type to:
210-
```ts
210+
```typescript
211211
Numeric: (property?: NumericOptions<number>) =>
212212
Type.Transform(Type.Union([Type.String(), Type.Number(property)]))
213213
.Decode((value) => {
@@ -231,7 +231,7 @@ We can't wait to see what you will brings with the introduction of `t.Transform`
231231
With an introduction **Transform**, we have add a new type like `t.ObjectString` to automatically decode a value of Object in request.
232232

233233
This is useful when you have to use **multipart/formdata** for handling file uploading but doesn't support object. You can now just use `t.ObjectString()` to tells Elysia that the field is a stringified JSON, so Elysia can decode it automatically.
234-
```ts
234+
```typescript
235235
new Elysia({
236236
cookie: {
237237
secret: 'Fischl von Luftschloss Narfidort'
@@ -279,7 +279,7 @@ To summarize, Elysia allows us to decorate and request and store with any value
279279
As the name suggest, this allow us to remap existing `state`, `decorate`, `model`, `derive` to anything we like to prevent name collision, or just wanting to rename a property.
280280

281281
By providing a function as a first parameters, the callback will accept current value, allowing us to remap the value to anything we like.
282-
```ts
282+
```typescript
283283
new Elysia()
284284
.state({
285285
a: "a",
@@ -290,7 +290,7 @@ new Elysia()
290290
```
291291

292292
This is useful when you have to deal with a plugin that has some duplicate name, allowing you to remap the name of the plugin:
293-
```ts
293+
```typescript
294294
new Elysia()
295295
.use(
296296
plugin
@@ -304,11 +304,11 @@ new Elysia()
304304
Remap function can be use with `state`, `decorate`, `model`, `derive` to helps you define a correct property name and preventing name collision.
305305

306306
### Affix
307-
The provide a smoother experience, some plugins might have a lot of property value which can be overwhelming to remap one-by-one.
307+
To provide a smoother experience, some plugins might have a lot of property value which can be overwhelming to remap one-by-one.
308308

309-
The **Affix** function which consists of **prefix** and **suffix**, allowing us to remap all property of an instance.
309+
The **Affix** function, which consists of a **prefix** and **suffix**, allows us to remap all properties of an instance, preventing the name collision of the plugin.
310310

311-
```ts
311+
```typescript
312312
const setup = new Elysia({ name: 'setup' })
313313
.decorate({
314314
argon: 'a',
@@ -329,7 +329,7 @@ Allowing us to bulk remap a property of the plugin effortlessly, preventing the
329329
By default, **affix** will handle both runtime, type-level code automatically, remapping the property to camelCase as naming convention.
330330

331331
In some condition, you can also remap `all` property of the plugin:
332-
```ts
332+
```typescript
333333
const app = new Elysia()
334334
.use(
335335
setup
@@ -345,7 +345,7 @@ With the introduction of Elysia 0.7, Elysia can now truly encapsulate an instanc
345345

346346
The new scope model can even prevent event like `onRequest` to be resolve on a main instance which is not possible.
347347

348-
```ts
348+
```typescript
349349
const plugin = new Elysia({ scoped: true, prefix: '/hello' })
350350
.onRequest(() => {
351351
console.log('In Scoped')

docs/essential/context.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ Using remap, Elysia will treat a returned object as a new property, removing any
201201
:::
202202
203203
## Affix
204-
The provide a smoother experience, some plugins might have a lot of property value which can be overwhelming to remap one-by-one.
204+
To provide a smoother experience, some plugins might have a lot of property value which can be overwhelming to remap one-by-one.
205205
206206
The **Affix** function which consists of **prefix** and **suffix**, allowing us to remap all property of an instance.
207207

docs/essential/life-cycle.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Elysia does the following for every request:
5050
- Modify `Context` before validation
5151
- Best for:
5252
- Mutate existing context to conform with validation.
53-
- Adding new context (derive this)
53+
- Adding new context (derive this)
5454
4. **Validation** (not interceptable)
5555
- Strictly validate incoming request provided by `Elysia.t`
5656
5. **Before Handle**
@@ -139,11 +139,11 @@ new Elysia()
139139

140140
The response should be listed as follows:
141141

142-
| Path | Content-Type |
143-
| ----- | ----------------------- |
144-
| / | text/html; charset=utf8 |
145-
| /hi | text/html; charset=utf8 |
146-
| /none | text/; charset=utf8 |
142+
| Path | Content-Type |
143+
| ----- | ------------------------ |
144+
| / | text/html; charset=utf8 |
145+
| /hi | text/html; charset=utf8 |
146+
| /none | text/plain; charset=utf8 |
147147

148148
Events from other plugins are also applied to the route so the order of code is important.
149149

docs/validation/primitive-type.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,10 @@ t.Array(
239239
t.Number(),
240240
{
241241
/**
242-
* @default 1
243242
* Minimum number of items
244243
*/
245244
minItems: 1,
246245
/**
247-
* @default 5
248246
* Maximum number of items
249247
*/
250248
maxItems: 5

0 commit comments

Comments
 (0)