Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
169cbfe
:tada: feat: simplify query mechanism
SaltyAom Aug 19, 2025
1763ce3
:broom: chore: merge main
SaltyAom Aug 19, 2025
112368a
:wrench: fix: merge main
SaltyAom Aug 24, 2025
925a337
:tada: feat: standard schema
SaltyAom Aug 28, 2025
2398100
:wrench: fix: type error
SaltyAom Aug 28, 2025
6b683a6
:wrench: fix: type error
SaltyAom Aug 28, 2025
1a29660
:wrench: fix: standard schema edge case
SaltyAom Aug 28, 2025
c51af45
:wrench: fix: standard schema query parser
SaltyAom Aug 28, 2025
7b64087
:tada: feat: optimize type inference
SaltyAom Aug 29, 2025
da8119a
:tada: feat: optimize type inference
SaltyAom Aug 29, 2025
d4c2d2d
:blue_book: doc: update CHANGELOG
SaltyAom Aug 30, 2025
b94394c
:wrench: fix: test type error
SaltyAom Aug 31, 2025
56b8b48
:broom: chore: merge main
SaltyAom Aug 31, 2025
a709a22
:broom: chore: merge weirs
SaltyAom Aug 31, 2025
761292d
:tada: feat: standard schema as standalone schema
SaltyAom Aug 31, 2025
03891e6
:wrench: fix: standard schema type conflict
SaltyAom Aug 31, 2025
a43a607
:tada: feat: standard schema standalone validator
SaltyAom Aug 31, 2025
1fabcd3
:tada: feat: typebox force additionalProperties
SaltyAom Aug 31, 2025
96a8b13
:tada: feat: standard schema reference model
SaltyAom Sep 5, 2025
7eae435
:wrench: fix: reference model type
SaltyAom Sep 5, 2025
0ece58a
:tada: feat: add test cases
SaltyAom Sep 5, 2025
52aa1c3
Merge pull request #1381 from elysiajs/weirs-standard-schema
SaltyAom Sep 5, 2025
36b3417
:broom: chore: bump version
SaltyAom Sep 5, 2025
0cc6c50
:wrench: fix: #861 missing HEAD method when register route with GET
SaltyAom Sep 5, 2025
2a5b0cc
:tada: feat: optimize type
SaltyAom Sep 5, 2025
b869231
:tada: feat: optimize type
SaltyAom Sep 5, 2025
5129359
:wrench: fix: merge main
SaltyAom Sep 6, 2025
bffe687
:tada: feat: lifecycle type soundness
SaltyAom Sep 6, 2025
990cd32
:tada: feat: lifecycle type soundness test
SaltyAom Sep 7, 2025
a1166b7
:broom: chore: format stuff
SaltyAom Sep 7, 2025
e87b550
:tada: feat: macro modify schema
SaltyAom Sep 7, 2025
4561eda
:tada: feat: infer macro response to inline handler and response
SaltyAom Sep 7, 2025
ea8ef46
:tada: feat: infer macro response to inline handler and response
SaltyAom Sep 7, 2025
3f51556
:wrench: fix: remove prettifySchema
SaltyAom Sep 7, 2025
7fd26d6
:wrench: fix: conditional infer type
SaltyAom Sep 7, 2025
520230b
:tada: feat: improve soundness
SaltyAom Sep 7, 2025
2baa6b8
:tada: feat: improve soundness
SaltyAom Sep 7, 2025
249fab1
:tada: feat: improve soundness
SaltyAom Sep 7, 2025
63da7e8
:tada: feat: improve soundness and test case
SaltyAom Sep 8, 2025
d28b24a
:tada: feat: improve soundness and test case
SaltyAom Sep 8, 2025
b3b96c0
:tada: feat: improve soundness
SaltyAom Sep 8, 2025
50cc8f6
:tada: feat: greatly improve type soundness
SaltyAom Sep 8, 2025
7034649
:wrench: fix: #1392 ObjectString/ArrayString no longer produce defaul…
SaltyAom Sep 8, 2025
823015c
:broom: chore: dynamic cookie object parsing for standard schema
SaltyAom Sep 8, 2025
5e5106d
:tada: feat: type soundness merge possible path
SaltyAom Sep 8, 2025
834fb2b
:tada: feat: macro context should add to output declaration
SaltyAom Sep 8, 2025
6853c28
:tada: feat: macro context should add to output declaration
SaltyAom Sep 9, 2025
e331830
:tada: feat: macro context should add to output declaration
SaltyAom Sep 9, 2025
a6e7fb3
:broom: chore: clean up type
SaltyAom Sep 9, 2025
f828f95
:broom: chore: clean up type
SaltyAom Sep 9, 2025
f406bb6
:broom: chore: clean up type
SaltyAom Sep 9, 2025
864d91c
:tada: feat: macro extension in type level
SaltyAom Sep 9, 2025
aad5fb0
:tada: feat: macro extension
SaltyAom Sep 9, 2025
bddfd22
:tada: feat: macro extension
SaltyAom Sep 9, 2025
a82b139
:tada: feat: macro name
SaltyAom Sep 9, 2025
617e277
:tada: feat: macro name extends macro
SaltyAom Sep 9, 2025
7d9fc87
:tada: feat: macro name extends macro
SaltyAom Sep 9, 2025
015e227
:broom: chore: clean up
SaltyAom Sep 10, 2025
ff6cb5a
:broom: chore: clean up
SaltyAom Sep 10, 2025
41f02fe
:broom: chore: clean up
SaltyAom Sep 10, 2025
5706380
:wrench: fix: macro in inline lifecycle
SaltyAom Sep 12, 2025
0ecf51b
:tada: feat: responseValue
SaltyAom Sep 12, 2025
aa1b80f
:tada: feat: 1.4
SaltyAom Sep 12, 2025
4002f1a
Merge branch 'main' into weirs
SaltyAom Sep 12, 2025
ac4b961
:tada: feat: 1.4
SaltyAom Sep 12, 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
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# 1.4.0 - 13 Sep 2025
Feature:
- standard validator
- macro schema, macro extension, macro detail
- lifecycle type soundness
- type inference reduced by ~11%
- [#861](https://github.com/elysiajs/elysia/issues/861) missing HEAD method when register route with GET

Improvement
- [#861](https://github.com/elysiajs/elysia/issues/861) automatically add HEAD method when defining GET route

Change
- ObjectString/ArrayString no longer produce default value by default due to security reasons
- Cookie now dynamically parse when format is likely JSON
- export `fileType` for external file type validation for accurate response
- ObjectString/ArrayString no longer produce default value by default due to security reasons
- Cookie now dynamically parse when format is likely JSON

Breaking Change
- remove macro v1 due to non type soundness
- remove `error` function, use `status` instead
- deprecation notice for `response` in `mapResponse`, `afterResponse`, use `responseValue` instead

# 1.3.22 - 6 Sep 2025
Bug fix:
- safely unwrap t.Record
Expand Down
43 changes: 33 additions & 10 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 15 additions & 10 deletions example/a.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { Elysia, t } from '../src'
import { req } from '../test/utils'
import { Elysia, t } from 'elysia'

const app = new Elysia()
.get('/', () => 'SAFE', {
query: t.Record(t.String(), t.String())
})

const response = await app.handle(req('/?x=1'))

console.log(response.status)
new Elysia().group(
'/id/:id',
{
params: t.Object({
id: t.Number()
})
},
(app) =>
app.get('/:name', ({ params }) => params, {
params: t.Object({
name: t.String()
})
})
)
2 changes: 1 addition & 1 deletion example/custom-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const prettyJson = new Elysia()
if (response instanceof Object)
return new Response(JSON.stringify(response, null, 4))
})
.as('plugin')
.as('scoped')

new Elysia()
.use(prettyJson)
Expand Down
76 changes: 76 additions & 0 deletions example/openapi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { Elysia, t } from '../src'
import { openapi as OpenAPI } from '@elysiajs/openapi'
import { fromTypes } from '@elysiajs/openapi/gen'

const openapi = (a: any) =>
new Elysia().use((app) => {
app.use(
// @ts-ignore
OpenAPI(a)
)

return app
})

// Elysia 1.4: lifecycle event type soundness
export const app = new Elysia()
.use(
openapi({
references: fromTypes('example/openapi.ts')
})
)
.macro({
auth: {
response: {
409: t.Literal('Conflict')
},
beforeHandle({ status }) {
if (Math.random() < 0.05) return status(410)
},
resolve: () => ({ a: 'a' })
}
})
.onError(({ status }) => {
if (Math.random() < 0.05) return status(400)
})
.resolve(({ status }) => {
if (Math.random() < 0.05) return status(401)
})
.onBeforeHandle([
({ status }) => {
if (Math.random() < 0.05) return status(402)
},
({ status }) => {
if (Math.random() < 0.05) return status(403)
}
])
.guard({
beforeHandle: [
({ status }) => {
if (Math.random() < 0.05) return status(405)
},
({ status }) => {
if (Math.random() < 0.05) return status(406)
}
],
afterHandle({ status }) {
if (Math.random() < 0.05) return status(407)
},
error({ status }) {
if (Math.random() < 0.05) return status(408)
}
})
.post(
'/',
({ status }) =>
Math.random() < 0.05 ? status(409, 'Conflict') : 'Type Soundness',
{
auth: true,
response: {
411: t.Literal('Length Required')
}
}
)
.listen(3000)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Don’t start a server on import

Top-level listen(3000) creates side effects (eg, during tooling or type extraction). Gate it behind a main check.

-  .listen(3000)
+if (import.meta.main) {
+  app.listen(3000)
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.listen(3000)
if (import.meta.main) {
app.listen(3000)
}
🤖 Prompt for AI Agents
In example/openapi.ts around line 74, the file calls .listen(3000) at top-level
which causes side effects on import; remove the top-level listen call, export
the Express/Fastify app instance instead, and add a guarded startup block at the
bottom that only calls app.listen(3000) when the file is executed directly (use
a main-check such as if (typeof require !== 'undefined' ? require.main ===
module : import.meta?.main) { app.listen(3000) } or the project’s preferred
ESM/CJS pattern). Ensure the server port and any startup logging remain inside
that guarded block.


// app['~Routes']['post']['response']
2 changes: 1 addition & 1 deletion example/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const app = new Elysia()
},
message(ws, message) {
ws.publish('asdf', message)
ws.send('asdf', message)
ws.send(message)
}
})
.get('/publish/:publish', ({ params: { publish: text } }) => {
Expand Down
17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "elysia",
"description": "Ergonomic Framework for Human",
"version": "1.3.21",
"version": "1.4.0",
"author": {
"name": "saltyAom",
"url": "https://github.com/SaltyAom",
Expand Down Expand Up @@ -184,35 +184,38 @@
},
"dependencies": {
"cookie": "^1.0.2",
"exact-mirror": "0.1.6",
"exact-mirror": "0.2.2",
"fast-decode-uri-component": "^1.0.1"
},
"devDependencies": {
"@elysiajs/openapi": "^1.3.11",
"@types/bun": "^1.2.16",
"@types/cookie": "^1.0.0",
"@types/fast-decode-uri-component": "^1.0.0",
"@typescript-eslint/eslint-plugin": "^8.30.1",
"@typescript-eslint/parser": "^8.30.1",
"arktype": "^2.1.22",
"eslint": "^9.24.0",
"eslint-plugin-security": "^3.0.1",
"eslint-plugin-sonarjs": "^3.0.2",
"expect-type": "^1.2.1",
"file-type": "^20.4.1",
"memoirist": "^0.4.0",
"mitata": "^1.0.34",
"prettier": "^3.5.3",
"tsup": "^8.4.0",
"typescript": "^5.8.3"
"typescript": "^5.8.3",
"valibot": "^1.1.0",
"zod": "^4.1.5"
},
"peerDependencies": {
"@sinclair/typebox": ">= 0.34.0",
"@sinclair/typebox": ">= 0.34.0 < 1",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

TypeBox range too broad for 0.x (minors can be breaking)

Widening to < 1 risks breakage when 0.35+ lands. Safer to cap within 0.34.x.

-    "@sinclair/typebox": ">= 0.34.0 < 1",
+    "@sinclair/typebox": ">= 0.34.0 < 0.35",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"@sinclair/typebox": ">= 0.34.0 < 1",
"@sinclair/typebox": ">= 0.34.0 < 0.35",
🤖 Prompt for AI Agents
In package.json at line 211, the TypeBox semver range ">= 0.34.0 < 1" is too
broad for 0.x releases; change it to restrict updates within the 0.34.x line
(for example ">=0.34.0 <0.35.0") so minor releases in 0.35+ cannot be pulled in
and risk breaking changes.

"exact-mirror": ">= 0.0.9",
"file-type": ">= 20.0.0",
"openapi-types": ">= 12.0.0",
"typescript": ">= 5.0.0"
},
"optionalDependencies": {
"@sinclair/typebox": "^0.34.33",
"openapi-types": "^12.1.3"
"@sinclair/typebox": ">= 0.34.0 < 1",
"openapi-types": ">= 12.0.0"
}
}
11 changes: 7 additions & 4 deletions src/adapter/bun/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { status } from '../../error'
import { ELYSIA_TRACE } from '../../trace'

import type { AnyElysia } from '../..'
import type { InternalRoute } from '../../types'
import type { InternalRoute, InputSchema } from '../../types'

const allocateIf = (value: string, condition: unknown) =>
condition ? value : ''
Expand Down Expand Up @@ -38,7 +38,9 @@ const createContext = (
const needsQuery =
inference.query ||
!!route.hooks.query ||
!!route.standaloneValidators?.find((x) => x.query) ||
!!(route.hooks.standaloneValidator as InputSchema[])?.find(
(x) => x.query
) ||
app.event.request?.length

if (needsQuery) fnLiteral += getQi
Expand All @@ -65,7 +67,6 @@ const createContext = (
hasTrace || inference.url || needsQuery
) +
`redirect,` +
`error:status,` +
`status,` +
`set:{headers:` +
(isNotEmpty(defaultHeaders)
Expand Down Expand Up @@ -131,7 +132,9 @@ export const createBunRouteHandler = (app: AnyElysia, route: InternalRoute) => {
const needsQuery =
inference.query ||
!!route.hooks.query ||
!!route.standaloneValidators?.find((x) => x.query)
!!(route.hooks.standaloneValidator as InputSchema[])?.find(
(x) => x.query
)

// inference.query require declaring const 'qi'
if (hasTrace || needsQuery || app.event.request?.length) {
Expand Down
2 changes: 1 addition & 1 deletion src/adapter/bun/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ export const BunAdapter: ElysiaAdapter = {
) as any

const handleResponse = createHandleWSResponse(validateResponse)
const parseMessage = createWSMessageParser(parse)
const parseMessage = createWSMessageParser(parse as any)

let _id: string | undefined

Expand Down
1 change: 0 additions & 1 deletion src/adapter/web-standard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ export const WebStandardAdapter: ElysiaAdapter = {
`path:p,` +
`url:u,` +
`redirect,` +
`error:status,` +
`status,` +
`set:{headers:`

Expand Down
Loading
Loading