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/at-glance.md
+56-27Lines changed: 56 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -14,18 +14,26 @@ head:
14
14
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.
15
15
---
16
16
17
+
<scriptsetup>
18
+
importCardfrom'../components/nearl/card.vue'
19
+
importDeckfrom'../components/nearl/card-deck.vue'
20
+
</script>
21
+
17
22
# At glance
23
+
Elysia is an ergonomic web framework for building backend servers with Bun.
18
24
19
-
Elysia is designed with familiar API from Express and Fastify with extensive support for TypeScript, modern JavaScript API, and optimized for Bun.
25
+
Designed with simplicity and type safety in mind with familiar API with extensive support for TypeScript, optimized for Bun.
20
26
21
27
Here's a simple hello world in Elysia.
22
28
23
29
```typescript
24
30
import { Elysia } from'elysia'
25
31
26
32
newElysia()
27
-
.get('/', () =>'Hello Elysia')
28
-
.listen(3000)
33
+
.get('/', () =>'hi')
34
+
.get('/user/:id', ({ params: { id }}) =>id)
35
+
.post('/form', ({ body }) =>body)
36
+
.listen(8080)
29
37
```
30
38
31
39
Navigate to [localhost:3000](http://localhost:3000/) and it should show 'Hello Elysia' as a result.
@@ -38,39 +46,40 @@ Elysia can outperform most of the web frameworks available today<a href="#ref-1"
38
46
39
47
| Framework | Runtime | Average | Plain Text | Dynamic Parameters | JSON Body |
Elysia is built with a complex type system trying to infer every possible detail from simple path parameters to full-blown recursive instance deep merge to provide you the most out of TypeScript.
63
+
Elysia is designed to help you write less TypeScript.
64
+
65
+
Elysia's Type System is fine-tuned to infer your code into type automatically without needing to write explicit TypeScript while providing type-safety for both runtime and compile time to provide you with the most ergonomic developer experience.
57
66
58
67
Take a look at this example:
59
68
60
69
```typescript
61
70
import { Elysia } from'elysia'
62
71
63
72
newElysia()
64
-
.get('/id/:id', ({ params: { id } }) =>id)
73
+
.get('/user/:id', ({ params: { id } }) =>id)
65
74
.listen(3000)
66
75
```
67
76
68
-
The above code allows you to create a path parameter with the name of id, the value that passes after `/id/` will be reflected in `params.id`.
69
-
70
-
In most framework, you need to provide a generic type to the **id** parameter while Elysia understand that `params.id` will always be available and type as **string**. Elysia then infers this type without any manual type reference needed.
77
+
The above code create a path parameter "id", the value that replace `:id` will be passed to `params.id` both in runtime and type without manual type declaration.
71
78
72
79
Elysia's goal is to help you write less TypeScript and focus more on Business logic. Let the complex type be handled by the framework.
73
80
81
+
TypeScript is not needed to use Elysia, but it's recommended to use Elysia with TypeScript.
82
+
74
83
## Unified Type
75
84
76
85
To take a step further, Elysia provide **Elysia.t**, a schema builder to validate type and value in both runtime and compile-time to create a single source of truth for your data-type. Elysia refers this term as **Unified Type**.
@@ -81,7 +90,7 @@ Let's modify the previous code to accept only a numeric value instead of a strin
81
90
import { Elysia, t } from'elysia'
82
91
83
92
newElysia()
84
-
.get('/id/:id', ({ params: { id } }) =>id, {
93
+
.get('/user/:id', ({ params: { id } }) =>id, {
85
94
params: t.Object({
86
95
id: t.Numeric()
87
96
})
@@ -105,7 +114,7 @@ import { swagger } from '@elysiajs/swagger'
105
114
106
115
newElysia()
107
116
.use(swagger())
108
-
.get('/id/:id', ({ params: { id } }) =>id, {
117
+
.get('/user/:id', ({ params: { id } }) =>id, {
109
118
params: t.Object({
110
119
id: t.Numeric()
111
120
})
@@ -127,7 +136,7 @@ import { swagger } from '@elysiajs/swagger'
With Eden, you can use the existing Elysia type to query Elysia server **without code generation** and synchronize type for both frontend and backend automatically.
154
163
155
164
Elysia is not only about helping you to create a confident backend but for all that is beautiful in this world.
156
165
166
+
## Platform Agnostic
167
+
168
+
Elysia was designed but was **not limited to Bun**. Being [WinterCG compliant](https://wintercg.org/) allows you to deploy the Elysia server on Cloudflare Worker, Vercel Edge Function, and most other runtimes that support Web Standard Request.
169
+
170
+
## Our Community
171
+
172
+
If you have questions or get stuck about Elysia, feel free to ask our community on GitHub Discussions, Discord, and Twitter.
<smallid="ref-1">1. Measure in requests/second. The benchmark for parsing query, path parameter and set response header on Debian 11, Intel i7-13700K tested on Bun 0.7.2 on 6 Aug 2023. See the benchmark condition [here](https://github.com/SaltyAom/bun-http-framework-benchmark/tree/c7e26fe3f1bfee7ffbd721dbade10ad72a0a14ab#results).</small>
Copy file name to clipboardExpand all lines: docs/blog.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -25,9 +25,9 @@ head:
25
25
<Blogs
26
26
:blogs="[
27
27
{
28
-
title: 'Introducing support for Scalar - Elysia',
29
-
href: '/blog/elysia-scalar',
30
-
detail: 'We are changing API documentation provider to Scalar instead of Swagger UI by default. Scalar is a modern, beautiful API references for OpenAPI compatible, and customizable built on-top of Vue. Elysia now ship @elysia/swagger package by using Scalar as a default provider, with option to switch back to Swagger UI if need.'
28
+
title: 'Elysia 1.0 - Lament of the Fallen',
29
+
href: '/blog/elysia-10',
30
+
detail: 'Introducing Sucrose, a better static code analysis engine, improved starts up time up to 14x, remove 40 routes/instance limitation, faster type inference up to ~3.8x, Eden Treaty 2, Hook type (breaking change), and inline error for strict type check.'
31
31
},
32
32
{
33
33
title: 'Introducing Elysia 0.8 - Gate of Steiner',
0 commit comments