Skip to content

release 1.3: Herta #1141

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

Merged
merged 117 commits into from
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
f5ceaf6
:tada: feat: init
SaltyAom Mar 2, 2025
b887486
:tada: feat: systemRouter
SaltyAom Mar 2, 2025
95ec387
:wrench: fix: redundant check when using encode
SaltyAom Mar 2, 2025
c98c279
:wrench: fix(systemRouter): using query
SaltyAom Mar 2, 2025
3808b7e
:tada: feat: sucrose cache
SaltyAom Mar 3, 2025
06243bd
:tada: feat: sucrose cache
SaltyAom Mar 3, 2025
108463e
:tada: feat: sucrose cache
SaltyAom Mar 3, 2025
264c8b7
:tada: feat: json accelerator
SaltyAom Mar 3, 2025
786fd0a
:tada: feat: exact mirror
SaltyAom Mar 4, 2025
f227e57
:tada: feat: improve accelerate code
SaltyAom Mar 4, 2025
be540b7
:tada: feat: improve accelerate code
SaltyAom Mar 4, 2025
e5d8dd7
:tada: feat: improve accelerate code
SaltyAom Mar 4, 2025
ab23df6
:broom: chore: merge main
SaltyAom Mar 6, 2025
f83be28
:broom: chore: merge main
SaltyAom Mar 6, 2025
c137799
:tada: feat: ref
SaltyAom Mar 14, 2025
d748777
:tada: feat: ref
SaltyAom Mar 14, 2025
78ef2d7
:tada: feat: ref
SaltyAom Mar 14, 2025
6218bee
:tada: feat: noValidate
SaltyAom Mar 14, 2025
72b59ad
:blue_book: doc(config): standalone validator
SaltyAom Mar 28, 2025
2264a5d
:tada: feat: optimize type inference
SaltyAom Mar 28, 2025
0e04e03
:tada: feat: remove index route on root
SaltyAom Mar 28, 2025
0d04d1f
:tada: feat: remove index route on root
SaltyAom Mar 28, 2025
c52095a
:tada: feat: use universal type
SaltyAom Mar 28, 2025
759a075
:wrench: fix: typebox integer type
SaltyAom Mar 28, 2025
c3d0c81
:tada: feat: apply optimize type inference on all method
SaltyAom Mar 28, 2025
b50f7aa
:tada: feat: encode schema
SaltyAom Mar 28, 2025
8594b6f
:broom: chore: refactor type system
SaltyAom Mar 29, 2025
bf9a847
:broom: chore: optimize type
SaltyAom Mar 29, 2025
438599c
:broom: chore: optimize inline/macro type
SaltyAom Mar 29, 2025
7b76508
:broom: chore: optimize ws type
SaltyAom Mar 29, 2025
ad2cdf9
:broom: chore: refactor merge multiple instances
SaltyAom Mar 29, 2025
c2b758a
:broom: chore: refactor merge multiple instances
SaltyAom Mar 29, 2025
489dbd6
:tada: feat: intersect standalone schema
SaltyAom Mar 30, 2025
c178c24
:tada: feat: add test case for standalone schema
SaltyAom Mar 30, 2025
724a198
:tada: feat: optimize type
SaltyAom Mar 30, 2025
e0920f4
:tada: feat: optimize type
SaltyAom Mar 30, 2025
755f0a3
:wrench: fix: decorator not defined when using bun system router
SaltyAom Apr 1, 2025
91ff26a
:broom: chore: use reconcile when necessary
SaltyAom Apr 8, 2025
1d2c662
:broom: refactor: map handler
SaltyAom Apr 11, 2025
41d58e2
:broom: chore: refactor stuff
SaltyAom Apr 15, 2025
a84b2b9
:broom: chore: minify stuff
SaltyAom Apr 15, 2025
7e2f35b
:broom: chore: minify stuff
SaltyAom Apr 15, 2025
acfd651
:broom: chore: adjust build script
SaltyAom Apr 15, 2025
9a26c98
:broom: chore: use fast-decode-uri-component
SaltyAom Apr 15, 2025
ee40b9c
:broom: chore: update dependencies
SaltyAom Apr 15, 2025
9d59709
:broom: chore: update dependencies
SaltyAom Apr 15, 2025
8c5c647
:broom: chore: use plain object for routeTree
SaltyAom Apr 15, 2025
067dfe7
:tada: feat: optimize memory usage
SaltyAom Apr 15, 2025
269cae8
:tada: feat: optimize memory usage
SaltyAom Apr 15, 2025
eebe138
:tada: feat: optimize memory usage
SaltyAom Apr 15, 2025
6889198
:wrench: fix: remove heap.json
SaltyAom Apr 15, 2025
666b0b9
:broom: chore: optimize stuff
SaltyAom Apr 15, 2025
0eb669d
:broom: chore: reduce object cloning, dynamically create cookie valid…
SaltyAom Apr 17, 2025
0c2ba37
:broom: chore: optimize memory usage on Elysia.add
SaltyAom Apr 17, 2025
3078272
:broom: chore: optimize memory usage on Elysia.add
SaltyAom Apr 17, 2025
4878e35
:broom: chore: optimize memory usage on Elysia.add
SaltyAom Apr 17, 2025
67c1169
:tada: feat: add file-type to validate file type
SaltyAom Apr 18, 2025
0cb3813
:tada: feat: add file-type to validate file type
SaltyAom Apr 18, 2025
376e5a1
:tada: feat: dynamic import file type
SaltyAom Apr 18, 2025
a9dd188
:tada: feat: conditionally warn if file-type is required
SaltyAom Apr 18, 2025
0a09846
:tada: feat: conditionally warn if file-type is required
SaltyAom Apr 18, 2025
7fcaf42
:tada: feat: conditionally warn if file-type is required
SaltyAom Apr 18, 2025
b1a5eb1
:tada: feat: conditionally warn if file-type is required
SaltyAom Apr 18, 2025
1779444
:tada: feat: conditionally warn if file-type is required
SaltyAom Apr 18, 2025
54a04cb
:broom: chore: rename error to status
SaltyAom Apr 18, 2025
a0e3e51
:wrench: fix: bun system router stuff
SaltyAom Apr 19, 2025
ee78a7a
:wrench: fix: bun system router stuff
SaltyAom Apr 19, 2025
f6a55c5
:tada: feat: conditionally warn if file-type is required
SaltyAom Apr 19, 2025
72d3aa8
:broom: chore: prefers routes over static in Bun.serve config
SaltyAom Apr 19, 2025
82b4e0c
:wrench: fix: accelerate not handling content type
SaltyAom Apr 19, 2025
a148134
feat: optimize start index for finding delimiter of a content type he…
SaltyAom Apr 21, 2025
15c5af4
feat: optimize start index for finding delimiter of a content type he…
SaltyAom Apr 22, 2025
92b4ae1
:tada: feat: add schema.trusted for string
SaltyAom Apr 22, 2025
16427a7
:tada: feat: escaped name for decorators
SaltyAom Apr 22, 2025
75aaa33
:broom: chore: micro-optimization
SaltyAom Apr 22, 2025
d0acbb5
:broom: chore: micro-optimization
SaltyAom Apr 22, 2025
d5e7d4a
:broom: chore: micro-optimization
SaltyAom Apr 22, 2025
f69b728
:broom: chore: micro-optimization
SaltyAom Apr 22, 2025
c3ea2ae
:tada: feat: promise static response
SaltyAom Apr 22, 2025
a707be1
:wrench: fix: t.Files
SaltyAom Apr 22, 2025
3250e09
:wrench: fix: handle empty space on Date query
SaltyAom Apr 22, 2025
3720a04
:tada: feat: add sanitize options
SaltyAom Apr 23, 2025
521dddb
:tada: feat: add sanitize options
SaltyAom Apr 23, 2025
b79a90b
:tada: feat: handle recursion serialization
SaltyAom Apr 24, 2025
67bc157
:tada: feat: handle recursion serialization
SaltyAom Apr 24, 2025
ebf0fb5
:broom: chore: update dependency
SaltyAom Apr 24, 2025
e9c793f
:wrench: fix: json accelerator is not generated
SaltyAom Apr 25, 2025
583d23c
:broom: chore: using dependency instead of inline
SaltyAom Apr 25, 2025
cad952f
:wrench: fix: ignore compiled server from release
SaltyAom Apr 25, 2025
3d21592
:wrench: fix: conditionally apply cleaner
SaltyAom Apr 25, 2025
4d54eec
:wrench: fix: nested try-catch in clea
SaltyAom Apr 25, 2025
c782970
:wrench: fix: nested try-catch in clea
SaltyAom Apr 25, 2025
cfb4ace
:broom: chore: remove json accelerator
SaltyAom Apr 25, 2025
7553218
:broom: chore: keep stack trace on ParseError
SaltyAom Apr 25, 2025
dc79ce8
:wrench: fix: use label for nested switch
SaltyAom Apr 25, 2025
60415dd
:broom: chore: use difference handler for each adapter
SaltyAom Apr 25, 2025
c8dd685
:broom: chore: use difference handler for each adapter
SaltyAom Apr 25, 2025
648408a
:broom: chore: use difference handler for each adapter
SaltyAom Apr 25, 2025
87cab8b
:broom: chore: rewrite parse query
SaltyAom Apr 25, 2025
754ccf5
:broom: chore: rewrite parse query
SaltyAom Apr 25, 2025
b6b24e8
:broom: chore: rewrite parse query
SaltyAom Apr 25, 2025
71368d7
:tada: feat: get params only if route is dynamic on bun router
SaltyAom Apr 25, 2025
334833a
:broom: chore: some stuff i forgor
SaltyAom Apr 25, 2025
7199fc5
:tada: feat: mount trace
SaltyAom Apr 28, 2025
bbd83a9
:tada: feat: mount trace
SaltyAom Apr 28, 2025
8407fd9
:wrench: fix: general bug fix
SaltyAom May 1, 2025
dcbd815
:tada: feat: get global definition
SaltyAom May 1, 2025
727767e
:tada: feat: union file extension check
SaltyAom May 2, 2025
57ff9cd
:broom: chore: refactor composeErrorHandler
SaltyAom May 2, 2025
0e77530
:wrench: fix: use StaticDecode to unwrap TImport
SaltyAom May 4, 2025
12a463c
:wrench: fix: use StaticDecode to unwrap TImport
SaltyAom May 4, 2025
e6ca813
:wrench: fix: use StaticDecode to unwrap TImport
SaltyAom May 4, 2025
63e305b
:wrench: fix: custom t.Transform, unwrap macro with hook function
SaltyAom May 5, 2025
85c28b3
:wrench: fix: #1165
SaltyAom May 5, 2025
4bc4ecd
:wrench: fix: ws type
SaltyAom May 5, 2025
d39ea95
:wrench: fix: #1177 cookie does not sign when an error is thrown
SaltyAom May 5, 2025
72c89db
:tada: release: 1.3
SaltyAom May 5, 2025
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
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
.husky
.eslintrc.json

bun.lock
bun.lockb
node_modules
tsconfig.json
CHANGELOG.md
heap.json

example
tests
Expand All @@ -35,3 +37,4 @@ trace
build.ts
.scannerwork
src
server
59 changes: 59 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,62 @@
# 1.3.0
Feature:
- add `exactMirror`
- add `systemRouter` config
- `standalone Validator`
- add `Elysia.Ref` for referencing schema with autocompletion instead of `t.Ref`
- support Ref inside inline schema
- add sucrose cache
- new validation `t.Form`, `t.NoValidate`
- use `file-type` to check file type
- add `INVALID_FILE_TYPE` error
- add `sanitize` options

Improvement:
- `encodeSchema` now stable and enabled by default
- optimize types
- reduce redundant type check when using Encode
- optimize isAsync
- unwrap Definition['typebox'] by default to prevent unnecessary UnwrapTypeModule call
- Elysia.form can now be type check
- refactor type-system
- refactor `_types` into `~Types`
- using aot compilation to check for custom Elysia type, eg. Numeric
- refactor `app.router.static`, and move static router code generation to compile phase
- optimize memory usage on `add`, `_use`, and some utility functions
- improve start up time on multiple route
- dynamically create cookie validator as needed in compilation process
- reduce object cloning
- optimize start index for finding delimiter of a content type header
- Promise can now be a static response
- `ParseError` now keeps stack trace
- refactor `parseQuery` and `parseQueryFromURL`
- add `config` options to `mount`
- recompile automatically after async modules is mounted
- support macro on when hook has function
- support resolve macro on ws
- [#1146](https://github.com/elysiajs/elysia/pull/1146) add support to return web API's File from handler
- [#1165](https://github.com/elysiajs/elysia/pull/1165) skip non-numeric status codes in response schema validation
- [#1177](https://github.com/elysiajs/elysia/issues/1177) cookie does not sign when an error is thrown

Bug fix:
- `Response` returned from `onError` is using octet stream
- unintentional memory allocation when using `mergeObjectArray`
- handle empty space on Date query

Change:
- only provide `c.request` to mapResponse when `maybeStream` is true
- use plain object for `routeTree` instead of `Map`
- remove `compressHistoryHook` and `decompressHistoryHook`
- webstandard handler now return `text/plain` if not on Bun
- use non const value for `decorate` unless explicitly specified
- `Elysia.mount` now set `detail.hide = true` by default

Breaking Change:
- remove `as('plugin')` in favor of `as('scoped')`
- remove root `index` for Eden Treaty
- remove `websocket` from `ElysiaAdapter`
- remove `inference.request`

# 1.2.25 - 6 Mar 2025
Bug fix:
- [#1108](https://github.com/elysiajs/elysia/issues/1108) use validation response instead of return type when schema is provided
Expand Down
21 changes: 10 additions & 11 deletions build.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { $ } from 'bun'
import { build, type Options } from 'tsup'

const external = ['@sinclair/typebox', 'file-type']

const tsupConfig: Options = {
entry: ['src/**/*.ts'],
splitting: false,
sourcemap: false,
clean: true,
bundle: false,
minify: false
bundle: true,
minifySyntax: true,
minifyWhitespace: false,
minifyIdentifiers: false,
target: 'node20',
external
// outExtension() {
// return {
// js: '.js'
Expand All @@ -20,15 +26,13 @@ await Promise.all([
build({
outDir: 'dist',
format: 'esm',
target: 'node20',
cjsInterop: false,
...tsupConfig
}),
// ? tsup cjs
build({
outDir: 'dist/cjs',
format: 'cjs',
target: 'node20',
// dts: true,
...tsupConfig
})
Expand Down Expand Up @@ -74,13 +78,8 @@ await Bun.build({
identifiers: false
},
target: 'bun',
sourcemap: 'external',
external: [
'@sinclair/typebox',
'cookie',
'fast-decode-uri-component',
'memoirist'
]
sourcemap: 'linked',
external
})

await Promise.all([
Expand Down
760 changes: 760 additions & 0 deletions bun.lock

Large diffs are not rendered by default.

Binary file removed bun.lockb
Binary file not shown.
27 changes: 6 additions & 21 deletions example/a.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
import { Elysia, error, t } from '../src'
import { req } from '../test/utils'
import { Elysia, t } from '../src'

const app = new Elysia().mount(
'/test',
async (req) => new Response(await req.text())
)

const testBody = JSON.stringify({ hello: 'world' })
const response = await app.handle(
new Request('http://localhost/test', {
method: 'POST',
body: testBody,
headers: {
'Content-Type': 'application/json'
}
const app = new Elysia()
.get('/', ({ request }) => {
request.url
})
)
.listen(3000)

const responseBody = await response.text()
console.log(responseBody)
console.log(response.status)
// expect(response.status).toBe(200)
// expect(responseBody).toBe(testBody)
// console.log(app.routes[0].compile().toString())
44 changes: 13 additions & 31 deletions example/stress/instance.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,25 @@
import { Elysia, t } from '../../src'
import { generateHeapSnapshot } from 'bun'

const total = 500

const apps = []

const setup = (n = 0) => {
let app = new Elysia()

for (let i = 0; i < 2; i++) {
// app = app.decorate(`a/${i + n * total}`, () => i)
app.get(`/a/${i + n * total}`, () => i)
}

apps.push(app)

return app
}
const total = 100
const sub = 5

const app = new Elysia()

const memory = process.memoryUsage().heapTotal / 1024 / 1024
const t1 = performance.now()

for (let i = 0; i < total; i++) app.use(setup(i))
for (let i = 0; i < total; i++) {
const plugin = new Elysia()

const memoryAfter = process.memoryUsage().heapTotal / 1024 / 1024
const took = performance.now() - t1
for (let j = 0; j < sub; j++) plugin.get(`/${i * sub + j}`, () => 'hi')

console.log(
Intl.NumberFormat().format(total),
'routes took',
+took.toFixed(4),
'ms'
)
console.log('Average', +(took / total).toFixed(4), 'ms / route')
console.log(memoryAfter - memory, 'MB memory used')
app.use(plugin)
}

const snapshot = generateHeapSnapshot()
await Bun.write('heap.json', JSON.stringify(snapshot, null, 2))
const t2 = performance.now()

// console.log(app.router.history)
Bun.gc(true)

const memoryAfter = process.memoryUsage().heapTotal / 1024 / 1024
console.log(+(memoryAfter - memory).toFixed(2), 'MB memory used')
console.log(+(t2 - t1).toFixed(2), 'ms')
24 changes: 13 additions & 11 deletions example/stress/multiple-routes.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import { Elysia, t } from '../../src'
import { generateHeapSnapshot } from 'bun'

const total = 1000
const total = 500

{
console.log('Elysia')
const app = new Elysia()

const app = new Elysia({ precompile: true })
const t1 = performance.now()
const memory = process.memoryUsage().heapTotal / 1024 / 1024

for (let i = 0; i < total; i++)
app.onBeforeHandle(() => {
return { a: 'ok' }
}).get(`/id/${i}`, () => 'hello', {
body: t.String()
app.get(`/id/${i}`, () => 'hello', {
response: t.Object({
hello: t.String(),
world: t.String(),
extra: t.Object({
a: t.Array(t.String()),
b: t.Nullable(t.Array(t.String())),
name: t.String()
})
})
})

const memoryAfter = process.memoryUsage().heapTotal / 1024 / 1024
Expand All @@ -28,8 +32,6 @@ const total = 1000
)
console.log('Average', +(took / total).toFixed(4), 'ms / route')

const snapshot = generateHeapSnapshot()
await Bun.write('heap.json', JSON.stringify(snapshot, null, 2))

console.log(memoryAfter - memory, 'MB memory used')
console.log(((memoryAfter - memory) / total) * 1024, 'KB memory used')
}
Loading
Loading