Skip to content

Commit caaf17c

Browse files
committed
🎉 feat: release 1.2.11
1 parent 1ca0ef1 commit caaf17c

File tree

19 files changed

+319
-185
lines changed

19 files changed

+319
-185
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ trace
99
*.tsbuildinfo
1010
.wrangler
1111
.elysia
12+
heap.json

CHANGELOG.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
# 1.2.11
22
Feature:
3-
- Compressed lifecycle event
4-
- Lazily build radix tree for dynamic router
3+
- Reduce memory usage:
4+
- Compressed lifecycle event
5+
- Avoid unnecessary declaration in compose.ts
6+
- Lazily build radix tree for dynamic router
7+
8+
Change:
9+
- Update TypeBox to 0.34.15
10+
11+
Bug fix:
12+
- [#1039](vhttps://github.com/elysiajs/elysia/issues/1039) Elysia fails to start with an error inside its own code when using decorate twice with Object.create(null)
13+
- [#1005](https://github.com/elysiajs/elysia/issues/1005) Parsing malformed body with NODE_ENV 'production' results in UNKNOWN error
14+
- [#1037](https://github.com/elysiajs/elysia/issues/1037) Validation errors in production throw undefined is not an object (evaluating 'error2.schema')
15+
- [#1036](https://github.com/elysiajs/elysia/issues/1036) Support Bun HTML import
516

617
# 1.2.10 - 5 Jan 2025
718
Feature:

bun.lockb

-2 Bytes
Binary file not shown.

example/a.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
import { Elysia, t } from '../src'
2-
import { req } from '../test/utils'
1+
import { Elysia } from '../src'
32

4-
const app = new Elysia().get('/', () => 'Static Content')
3+
const app = new Elysia()
4+
.ws('/ws/:id', {
5+
message(ws, message) {
6+
ws.send(message)
7+
}
8+
})
9+
// .get('/ws/:id', () => 'hi')
10+
.listen(3000)
511

6-
console.dir(app, { depth: 10 })
12+
// console.log(app.fetch.toString())

example/html-import.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Elysia, t } from '../src'
2+
import Page from './index.html'
3+
4+
new Elysia()
5+
.get('/', Page)
6+
.get('/mika.mp4', Bun.file('test/kyuukurarin.mp4'))
7+
.listen(3000)

example/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<title>Bun HTML Import</title>
5+
</head>
6+
<body>
7+
<h1>Hi</h1>
8+
<video>
9+
<!-- <source src="/mika.mp4" type="video/mp4" /> -->
10+
</video>
11+
</body>
12+
</html>

example/stress/instance.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import { Elysia, t } from '../../src'
2+
import { generateHeapSnapshot } from 'bun'
23

3-
const total = 100
4+
const total = 500
5+
6+
const apps = []
47

58
const setup = (n = 0) => {
6-
const app = new Elysia()
9+
let app = new Elysia()
710

8-
for(let i = 0; i < 10; i++) {
9-
app.get(`/:a/${i + (n * total)}`, () => i)
11+
for (let i = 0; i < 2; i++) {
12+
// app = app.decorate(`a/${i + n * total}`, () => i)
13+
app.get(`/a/${i + n * total}`, () => i)
1014
}
1115

16+
apps.push(app)
17+
1218
return app
1319
}
1420

@@ -30,3 +36,8 @@ console.log(
3036
)
3137
console.log('Average', +(took / total).toFixed(4), 'ms / route')
3238
console.log(memoryAfter - memory, 'MB memory used')
39+
40+
const snapshot = generateHeapSnapshot()
41+
await Bun.write('heap.json', JSON.stringify(snapshot, null, 2))
42+
43+
// console.log(app.router.history)

example/stress/memoir.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { t } from '../../src'
2+
import { Memoirist } from 'memoirist'
3+
4+
const total = 1000
5+
const stack: Memoirist<any>[] = []
6+
7+
{
8+
const t1 = performance.now()
9+
const memory = process.memoryUsage().heapTotal / 1024 / 1024
10+
11+
for (let i = 0; i < total; i++) {
12+
for (let i = 0; i < 2; i++) {
13+
const router = new Memoirist()
14+
router.add('GET', '/a', () => 'Hello, World!')
15+
router.add('GET', '/b', () => 'Hello, World!')
16+
17+
stack.push(router)
18+
}
19+
}
20+
21+
const memoryAfter = process.memoryUsage().heapTotal / 1024 / 1024
22+
const took = performance.now() - t1
23+
24+
console.log(
25+
Intl.NumberFormat().format(total),
26+
'routes took',
27+
+took.toFixed(4),
28+
'ms'
29+
)
30+
console.log('Average', +(took / total).toFixed(4), 'ms / route')
31+
32+
console.log(memoryAfter - memory, 'MB memory used')
33+
}

example/stress/multiple-routes.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1-
import { Elysia } from '../../src'
1+
import { Elysia, t } from '../../src'
2+
import { generateHeapSnapshot } from 'bun'
23

34
const total = 1000
45

56
{
67
console.log('Elysia')
78

89
const app = new Elysia({ precompile: true })
9-
const t = performance.now()
10+
const t1 = performance.now()
1011
const memory = process.memoryUsage().heapTotal / 1024 / 1024
1112

12-
for (let i = 0; i < total; i++) app.get(`/id/${i}`, () => 'hello')
13+
for (let i = 0; i < total; i++)
14+
app.onBeforeHandle(() => {
15+
return { a: 'ok' }
16+
}).get(`/id/${i}`, () => 'hello', {
17+
body: t.String()
18+
})
1319

1420
const memoryAfter = process.memoryUsage().heapTotal / 1024 / 1024
15-
const took = performance.now() - t
21+
const took = performance.now() - t1
1622

1723
console.log(
1824
Intl.NumberFormat().format(total),
@@ -22,5 +28,8 @@ const total = 1000
2228
)
2329
console.log('Average', +(took / total).toFixed(4), 'ms / route')
2430

31+
const snapshot = generateHeapSnapshot()
32+
await Bun.write('heap.json', JSON.stringify(snapshot, null, 2))
33+
2534
console.log(memoryAfter - memory, 'MB memory used')
2635
}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "elysia",
33
"description": "Ergonomic Framework for Human",
4-
"version": "1.2.11-exp.1",
4+
"version": "1.2.11",
55
"author": {
66
"name": "saltyAom",
77
"url": "https://github.com/SaltyAom",
@@ -158,14 +158,14 @@
158158
"release": "npm run build && npm run test && npm publish"
159159
},
160160
"dependencies": {
161-
"@sinclair/typebox": "^0.34.13",
161+
"@sinclair/typebox": "^0.34.15",
162162
"cookie": "^1.0.2",
163163
"memoirist": "^0.3.0",
164164
"openapi-types": "^12.1.3"
165165
},
166166
"devDependencies": {
167167
"@types/benchmark": "^2.1.5",
168-
"@types/bun": "^1.1.2",
168+
"@types/bun": "^1.2.0",
169169
"@types/cookie": "^1.0.0",
170170
"@typescript-eslint/eslint-plugin": "^6.17.0",
171171
"@typescript-eslint/parser": "^6.17.0",

0 commit comments

Comments
 (0)