Skip to content

Commit c047fb4

Browse files
committed
🔧 fix: use system router
1 parent 250dec6 commit c047fb4

File tree

6 files changed

+7
-48
lines changed

6 files changed

+7
-48
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# 1.4.22
22
Bug fix:
33
- ValueError with summary missing types
4+
- Elysia not using Bun.routes
45

56
# 1.4.21 - 4 Jan 2026
67
Improvement:

example/a.ts

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,3 @@
1-
import { Elysia, t } from '../src'
1+
import { Elysia } from '../src'
22

3-
export const errorHandler = new Elysia({ name: "error-handler" })
4-
.onError(({ code, error, status }) => {
5-
switch (code) {
6-
case "VALIDATION": {
7-
const allErrors = error.detail
8-
9-
return status(422, {
10-
status: 422,
11-
message: error.valueError?.message,
12-
details: {
13-
location: error.type,
14-
rejected_value: error.value,
15-
expected: error.expected,
16-
},
17-
})
18-
}
19-
case "NOT_FOUND": {
20-
return status(404, {
21-
status: 404,
22-
message: "Route not found",
23-
})
24-
}
25-
default: {
26-
const statusCode =
27-
"status" in error
28-
? (typeof error.status === "number" ? error.status : Number(error.status)) || 500
29-
: 500
30-
31-
let errMsg = "An error occurred"
32-
if (error instanceof Error && error.message) {
33-
errMsg = error.message
34-
}
35-
36-
return status(statusCode, {
37-
status: statusCode,
38-
message: errMsg,
39-
})
40-
}
41-
}
42-
})
43-
.as("scoped")
3+
const app = new Elysia().get('/', () => 'a').listen(3000)

src/adapter/bun/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const supportedMethods = {
8484
} as const
8585

8686
const mapRoutes = (app: AnyElysia) => {
87-
if (!app.config.aot || !app.config.systemRouter) return undefined
87+
if (!app.config.aot || app.config.systemRouter === false) return undefined
8888

8989
const routes = <Record<string, Function | Record<string, unknown>>>{}
9090

src/adapter/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export const responseToSetHeaders = (
136136
return set
137137
}
138138

139-
type CreateHandlerParameter = {
139+
interface CreateHandlerParameter {
140140
mapResponse(
141141
response: unknown,
142142
set: Context['set'],

src/compose.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { AnyElysia, Cookie } from './index'
33
import { Value, TransformDecodeError } from '@sinclair/typebox/value'
44
import {
55
Kind,
6-
OptionalKind,
76
TypeBoxError,
87
type TAnySchema,
98
type TSchema
@@ -372,11 +371,9 @@ const matchFnReturn = /(?:return|=>)\s?\S+\(|a(?:sync|wait)/
372371

373372
export const isAsync = (v: Function | HookContainer) => {
374373
const isObject = typeof v === 'object'
375-
376374
if (isObject && v.isAsync !== undefined) return v.isAsync
377375

378376
const fn = isObject ? v.fn : v
379-
380377
if (fn.constructor.name === 'AsyncFunction') return true
381378

382379
const literal: string = fn.toString()
@@ -388,7 +385,6 @@ export const isAsync = (v: Function | HookContainer) => {
388385
}
389386

390387
const result = matchFnReturn.test(literal)
391-
392388
if (isObject) v.isAsync = result
393389

394390
return result

src/type-system/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ export const fileType = async (
145145
const result = await fileTypeFromBlob(file)
146146
if (!result) throw new InvalidFileType(name, extension)
147147

148+
console.log(result, extension)
149+
148150
if (typeof extension === 'string')
149151
if (!checkFileExtension(result.mime, extension))
150152
throw new InvalidFileType(name, extension)

0 commit comments

Comments
 (0)