Skip to content

docs: correct grammatical errors #574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/at-glance.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ head:

- - meta
- name: 'description'
content: Designed with ergonomic design, extensive support for TypeScript, modern JavaScript API, optimized for Bun. Offers a unique experience unified type, and end-to-end type safety while maintaining excellent performance.
content: Designed with ergonomic design, extensive support for TypeScript, modern JavaScript API, optimized for Bun. Offers a unique experience with unified types, and end-to-end type safety while maintaining excellent performance.

- - meta
- property: 'og:description'
content: Designed with ergonomic design, extensive support for TypeScript, modern JavaScript API, optimized for Bun. Offers a unique experience unified type, and end-to-end type safety while maintaining excellent performance.
content: Designed with ergonomic design, extensive support for TypeScript, modern JavaScript API, optimized for Bun. Offers a unique experience with unified types, and end-to-end type safety while maintaining excellent performance.
---

<script setup>
Expand Down
2 changes: 1 addition & 1 deletion docs/blog/elysia-10.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ head:

Elysia 1.0 is the first stable release after development for 1.8 years.

Since started, we have always waiting for a framework that focuses on developer experience, velocity, and how to make writing code for humans, not a machine.
Since we started, we have always been waiting for a framework that focuses on developer experience, velocity, and how to make writing code for humans, not a machine.

We battle-test Elysia in various situations, simulate medium and large-scale projects, shipping code to clients and this is the first version that we felt confident enough to ship.

Expand Down
2 changes: 1 addition & 1 deletion docs/blog/elysia-11.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ new Elysia()

![jaeger showing collected trace automatically](/blog/elysia-11/jaeger.webp)

Elysia OpenTelemetry is will **collect span of any library compatible OpenTelemetry standard**, and will apply parent and child span automatically.
Elysia OpenTelemetry will **collect span of any library compatible with the OpenTelemetry standard**, and will apply parent and child span automatically.

In the code above, we apply `Prisma` to trace how long each query took.

Expand Down
10 changes: 5 additions & 5 deletions docs/blog/elysia-12.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ head:

- - meta
- name: 'description'
content: Introducing Adapter for universal runtime suppport, Object macro with resolve, Parser with custom name, WebSocket with lifecycle, TypeBox 0.34 with recursive type, and Eden validation inference.
content: Introducing Adapter for universal runtime support, Object macro with resolve, Parser with custom name, WebSocket with lifecycle, TypeBox 0.34 with recursive type, and Eden validation inference.

- - meta
- property: 'og:description'
content: Introducing Adapter for universal runtime suppport, Object macro with resolve, Parser with custom name, WebSocket with lifecycle, TypeBox 0.34 with recursive type, and Eden validation inference.
content: Introducing Adapter for universal runtime support, Object macro with resolve, Parser with custom name, WebSocket with lifecycle, TypeBox 0.34 with recursive type, and Eden validation inference.

- - meta
- property: 'og:image'
Expand All @@ -38,9 +38,9 @@ head:
shadow
>

Named after the song [Φ²](https://youtu.be/b9IkzWO63Fg) from album "At the Fingertip of the Sea" by HoyoMix as used in as in [**"You and Me"**](https://youtu.be/nz_Ra4G57A4).
Named after the song [Φ²](https://youtu.be/b9IkzWO63Fg) from album "At the Fingertip of the Sea" by HoyoMix as used in [**"You and Me"**](https://youtu.be/nz_Ra4G57A4).

Elysia 1.2 focus on commitment to expand universal runtime support and developer experience:
Elysia 1.2 focuses on commitment to expand universal runtime support and developer experience:
- [Adapter](#adapter)
- [Macro with resolve](#macro-with-resolve)
- [Parser](#parser)
Expand Down Expand Up @@ -92,7 +92,7 @@ We will continue to expand support for more runtimes in the future starting with
- uWebSocket.js

### Universal runtime API
To be comaptible with different runtime, Elysia now wrap over a hand-picked utility function to provide a consistent API across different runtime.
To be compatible with different runtime, Elysia now wraps over a hand-picked utility function to provide a consistent API across different runtime.

For example, in Bun you may use `Bun.file` to return a file response which is not available in Node.

Expand Down
12 changes: 6 additions & 6 deletions docs/blog/elysia-13.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ When comparing to the same code **without schema**, we see < 2% performance diff

This is huge.

Previously, you have to choose between safety and performance but as we close the performance gap between using and not using validation. But now you don't have to worry about it.
Previously, you had to choose between safety and performance as we close the performance gap between using and not using validation. But now you don't have to worry about it.

But now, we drop validation overhead from a significant amount to almost near zero without requiring any changes on your side.

Expand Down Expand Up @@ -150,13 +150,13 @@ We can then override a public schema by providing a schema in a route handler wh
![Elysia run with default override guard showing schema gets override](/blog/elysia-13/schema-override.webp)
> Elysia run with default override guard

But sometime we **don't want to override** a schema.
But sometimes we **don't want to override** a schema.

Instead we want it to work both allowing us to combine schemas instead of overriding them.

Starting from Elysia 1.3, we can do just that.

We can now tell Elysia to not to override it and instead treat it as its own by providing a schema as **standalone**.
We can now tell Elysia not to override it and instead treat it as its own by providing a schema as **standalone**.

```ts
import { Elysia } from 'elysia'
Expand All @@ -170,7 +170,7 @@ new Elysia()
})
```

As a result, we have a results that like merging a local and global schema together.
As a result, we have results that are like merging a local and global schema together.

![Elysia run with standalone merging multiple guard together](/blog/elysia-13/schema-standalone.webp)
> Elysia run with standalone merging multiple guard together
Expand All @@ -181,7 +181,7 @@ Elysia's type inference is already extremely fast.

We are really confident in our optimization of type inference and it's faster than most frameworks that use an express-like syntax.

However, our users with really **really** large scale with multiple routes and complex type inference.
However, our users with really **really** large scale applications with multiple routes and complex type inference.

We managed to **reduce type instantiation by half** in most cases, and measured up to 60% improvement in inference speed.

Expand All @@ -195,7 +195,7 @@ This should solve the problem with users who use heavy object/class for example
As a result, we should end up with faster IDE auto-completion, suggestion, type checking and Eden Treaty.

## Performance Improvement
We have refactored and optimized a lot of internal code which accumulate up to significant improvements.
We have refactored and optimized a lot of internal code which accumulates up to significant improvements.

### Route Registration

Expand Down
4 changes: 2 additions & 2 deletions docs/eden/fetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ head:
---

# Eden Fetch
A fetch-like alternative to Eden Treaty .
A fetch-like alternative to Eden Treaty.

With Eden Fetch can interact with Elysia server in a type-safe manner using Fetch API.
With Eden Fetch, you can interact with Elysia server in a type-safe manner using Fetch API.

---

Expand Down
20 changes: 10 additions & 10 deletions docs/eden/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ head:

- - meta
- name: 'description'
content: Elysia supports end-to-end type safety with Elysia Eden since start. End-to-end type-safety refers to a system in which every component of the system is checked for type consistency, meaning that data is passed between components only if the types of the data are compatible.
content: Elysia supports end-to-end type safety with Elysia Eden from the start. End-to-end type-safety refers to a system in which every component of the system is checked for type consistency, meaning that data is passed between components only if the types of the data are compatible.

- - meta
- property: 'og:description'
content: Elysia supports end-to-end type safety with Elysia Eden since start. End-to-end type-safety refers to a system in which every component of the system is checked for type consistency, meaning that data is passed between components only if the types of the data are compatible.
content: Elysia supports end-to-end type safety with Elysia Eden from the start. End-to-end type-safety refers to a system in which every component of the system is checked for type consistency, meaning that data is passed between components only if the types of the data are compatible.
---

# End-to-End Type Safety
Expand All @@ -23,14 +23,14 @@ End-to-end type safety is like making sure all the pieces of the track match up

For a framework to have end-to-end type safety means you can connect client and server in a type-safe manner.

Elysia provide end-to-end type safety **without code generation** out of the box with RPC-like connector, **Eden**
Elysia provides end-to-end type safety **without code generation** out of the box with an RPC-like connector, **Eden**

<video mute controls>
<source src="/eden/eden-treaty.mp4" type="video/mp4" />
Something went wrong trying to load video
</video>

Others framework that support e2e type safety:
Other frameworks that support e2e type safety:
- tRPC
- Remix
- SvelteKit
Expand All @@ -52,20 +52,20 @@ Hover over variable and function to see type definition.
Elysia allows you to change the type on the server and it will be instantly reflected on the client, helping with auto-completion and type-enforcement.

## Eden
Eden is a RPC-like client to connect Elysia **end-to-end type safety** using only TypeScript's type inference instead of code generation.
Eden is an RPC-like client to connect Elysia with **end-to-end type safety** using only TypeScript's type inference instead of code generation.

Allowing you to sync client and server types effortlessly, weighing less than 2KB.
It allows you to sync client and server types effortlessly, weighing less than 2KB.

Eden is consists of 2 modules:
Eden consists of 2 modules:
1. Eden Treaty **(recommended)**: an improved version RFC version of Eden Treaty
2. Eden Fetch: Fetch-like client with type safety.
2. Eden Fetch: Fetch-like client with type safety

Below is an overview, use-case and comparison for each module.

## Eden Treaty (Recommended)
Eden Treaty is an object-like representation of an Elysia server providing end-to-end type safety and a significantly improved developer experience.

With Eden Treaty we can connect interact Elysia server with full-type support and auto-completion, error handling with type narrowing, and creating type safe unit test.
With Eden Treaty we can interact with an Elysia server with full-type support and auto-completion, error handling with type narrowing, and create type-safe unit tests.

Example usage of Eden Treaty:
```typescript twoslash
Expand Down Expand Up @@ -131,5 +131,5 @@ const { data } = await fetch('/name/:name', {
```

::: tip NOTE
Unlike Eden Treaty, Eden Fetch doesn't provide Web Socket implementation for Elysia server
Unlike Eden Treaty, Eden Fetch doesn't provide Web Socket implementation for Elysia server.
:::
28 changes: 14 additions & 14 deletions docs/eden/treaty/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ import type { App } from './server'
const api = treaty<App>('localhost:3000')
```

You may or may not specified a protocol for URL endpoint.
You may or may not specify a protocol for URL endpoint.

Elysia will appends the endpoints automatically as follows:
Elysia will append the endpoints automatically as follows:
1. If protocol is specified, use the URL directly
2. If the URL is localhost and ENV is not production, use http
3. Otherwise use https

This also apply to Web Socket as well for determining between **ws://** or **wss://**.
This also applies to Web Socket as well for determining between **ws://** or **wss://**.

---

### Elysia Instance
If Elysia instance is passed, Eden Treaty will create a `Request` class and pass to `Elysia.handle` directly without creating a network request.

This allows us to interact with Elysia server directly without request overhead, or the need start a server.
This allows us to interact with Elysia server directly without request overhead, or the need to start a server.

```typescript
import { Elysia } from 'elysia'
Expand All @@ -61,13 +61,13 @@ const app = new Elysia()
const api = treaty(app)
```

If an instance is passed, generic is not needed to be pass as Eden Treaty can infers the type from a parameter directly.
If an instance is passed, generic is not needed to be passed as Eden Treaty can infer the type from a parameter directly.

This patterns is recommended for performing unit tests, or creating a type-safe reverse proxy server or micro-services.
This pattern is recommended for performing unit tests, or creating a type-safe reverse proxy server or micro-services.

## Options
2nd optional parameters for Eden Treaty to customize fetch behavior, accepting parameters as follows:
- [fetch](#fetch) - add default parameters to fetch intialization (RequestInit)
2nd optional parameter for Eden Treaty to customize fetch behavior, accepting parameters as follows:
- [fetch](#fetch) - add default parameters to fetch initialization (RequestInit)
- [headers](#headers) - define default headers
- [fetcher](#fetcher) - custom fetch function eg. Axios, unfetch
- [onRequest](#onrequest) - Intercept and modify fetch request before firing
Expand All @@ -87,7 +87,7 @@ treaty<App>('localhost:3000', {
})
```

All parameters that passed to fetch, will be passed to fetcher, which is an equivalent to:
All parameters that are passed to fetch will be passed to fetcher, which is equivalent to:
```typescript
fetch('http://localhost:3000', {
credentials: 'include'
Expand All @@ -114,7 +114,7 @@ fetch('localhost:3000', {
})
```

headers may accepts the following as parameters:
headers may accept the following as parameters:
- Object
- Function

Expand All @@ -130,7 +130,7 @@ treaty<App>('localhost:3000', {
```

### Function
You may specify a headers as a function to return custom headers based on condition
You may specify headers as a function to return custom headers based on condition

```typescript
treaty<App>('localhost:3000', {
Expand All @@ -151,7 +151,7 @@ headers function accepts 2 parameters:
- options `RequestInit`: Parameters that passed through 2nd parameter of fetch

### Array
You may define a headers function as an array if multiple conditions are need.
You may define a headers function as an array if multiple conditions are needed.

```typescript
treaty<App>('localhost:3000', {
Expand All @@ -172,7 +172,7 @@ Eden Treaty will **run all functions** even if the value is already returned.
Eden Treaty will prioritize the order headers if duplicated as follows:
1. Inline method - Passed in method function directly
2. headers - Passed in `config.headers`
- If `config.headers` is array, parameters that come after will be prioritize
- If `config.headers` is array, parameters that come after will be prioritized
3. fetch - Passed in `config.fetch.headers`

For example, for the following example:
Expand All @@ -190,7 +190,7 @@ api.profile.get({
})
```

This will be results in:
This will result in:
```typescript
fetch('http://localhost:3000', {
headers: {
Expand Down
6 changes: 3 additions & 3 deletions docs/eden/treaty/response.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ head:

- - meta
- name: 'og:description'
content: Eden Treaty is an object-like representation of an Elysia server, providing an end-to-end type safety, and a significantly improved developer experience. With Eden, we can fetch an API from Elysia server fully type-safe without code generation.
content: Eden Treaty is an object-like representation of an Elysia server, providing end-to-end type safety and a significantly improved developer experience. With Eden, we can fetch an API from Elysia server fully type-safe without code generation.

- - meta
- name: 'og:description'
content: Eden Treaty is an object-like representation of an Elysia server, providing an end-to-end type safety, and a significantly improved developer experience. With Eden, we can fetch an API from Elysia server fully type-safe without code generation.
content: Eden Treaty is an object-like representation of an Elysia server, providing end-to-end type safety and a significantly improved developer experience. With Eden, we can fetch an API from Elysia server fully type-safe without code generation.
---

# Response
Expand Down Expand Up @@ -70,7 +70,7 @@ const submit = async (name: string) => {
By default, Elysia infers `error` and `response` types to TypeScript automatically, and Eden will be providing auto-completion and type narrowing for accurate behavior.

::: tip
If the server responds with an HTTP status >= 300, then the value will be always be `null`, and `error` will have a returned value instead.
If the server responds with an HTTP status >= 300, then the value will always be `null`, and `error` will have a returned value instead.

Otherwise, response will be passed to `data`.
:::
Expand Down
10 changes: 5 additions & 5 deletions docs/eden/treaty/unit-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ head:

- - meta
- name: 'og:description'
content: Eden Treaty is an object-like representation of an Elysia server, providing an end-to-end type safety, and a significantly improved developer experience. With Eden, we can fetch an API from Elysia server fully type-safe without code generation.
content: Eden Treaty is an object-like representation of an Elysia server, providing end-to-end type safety and a significantly improved developer experience. With Eden, we can fetch an API from Elysia server fully type-safe without code generation.

- - meta
- name: 'og:description'
content: Eden Treaty is an object-like representation of an Elysia server, providing an end-to-end type safety, and a significantly improved developer experience. With Eden, we can fetch an API from Elysia server fully type-safe without code generation.
content: Eden Treaty is an object-like representation of an Elysia server, providing end-to-end type safety and a significantly improved developer experience. With Eden, we can fetch an API from Elysia server fully type-safe without code generation.
---

# Unit Test
According to [Eden Treaty config](/eden/treaty/config.html#urlorinstance) and [Unit Test](/patterns/unit-test), we may pass an Elysia instance to Eden Treaty directly to interact with Elysia server directly without sending a network request.

We may use this patterns to create a unit test with end-to-end type safety and type-level test all at once.
We may use this pattern to create a unit test with end-to-end type safety and type-level test all at once.

```typescript twoslash
// test/index.test.ts
Expand All @@ -29,7 +29,7 @@ const app = new Elysia().get('/hello', 'hi')
const api = treaty(app)

describe('Elysia', () => {
it('return a response', async () => {
it('returns a response', async () => {
const { data } = await api.hello.get()

expect(data).toBe('hi')
Expand All @@ -40,7 +40,7 @@ describe('Elysia', () => {
```

## Type safety test
To perform a type safety test, simply run **tsc** to test folders.
To perform a type safety test, simply run **tsc** on test folders.

```bash
tsc --noEmit test/**/*.ts
Expand Down
Loading