Skip to content

Commit 8407fd9

Browse files
committed
🔧 fix: general bug fix
1 parent bbd83a9 commit 8407fd9

File tree

9 files changed

+199
-152
lines changed

9 files changed

+199
-152
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Improvement:
3131
- `ParseError` now keeps stack trace
3232
- refactor `parseQuery` and `parseQueryFromURL`
3333
- add `config` options to `mount`
34+
- recompile automatically after async modules is mounted
3435

3536
Bug fix:
3637
- `Response` returned from `onError` is using octet stream

example/a.ts

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,9 @@
11
import { Elysia, t } from '../src'
2-
3-
const a = (request: Request) => new Response(request.url)
4-
5-
let url = ''
6-
let hasWrap = false
2+
import { req } from '../test/utils'
73

84
const app = new Elysia()
9-
.wrap((fn) => {
10-
console.log('A')
11-
12-
return fn
13-
})
14-
.mount('/', () => new Response('OK'))
5+
// .onRequest(async () => {})
6+
.mount('/auth', () => new Response('OK'))
157
.listen(3000)
168

17-
fetch('http://localhost:3000/a')
18-
19-
// app.handle(
20-
// new Request('http://localhost/', {
21-
// method: 'POST',
22-
// headers: {
23-
// 'Content-Type': 'application/json'
24-
// },
25-
// body: JSON.stringify({ hello: 'world' })
26-
// })
27-
// ).then((x) => x.json())
28-
29-
// console.log(app.fetch.toString())
30-
// console.log(app.routes[0].compile().toString())
9+
console.log(app.router)

package.json

Lines changed: 1 addition & 1 deletion
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.3.0-exp.69",
4+
"version": "1.3.0-exp.70",
55
"author": {
66
"name": "saltyAom",
77
"url": "https://github.com/SaltyAom",

src/adapter/bun/compose.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { sucrose, type Sucrose } from '../../sucrose'
2-
import { createHoc, createOnRequestHandler } from '../../compose'
2+
import { createHoc, createOnRequestHandler, isAsync } from '../../compose'
33

44
import { randomId, ELYSIA_REQUEST_ID, redirect, isNotEmpty } from '../../utils'
55
import { status } from '../../error'
66
import { ELYSIA_TRACE } from '../../trace'
77

88
import type { AnyElysia } from '../..'
99
import type { InternalRoute } from '../../types'
10-
import { isDeno } from '../../universal/utils'
1110

1211
const allocateIf = (value: string, condition: unknown) =>
1312
condition ? value : ''
@@ -119,7 +118,7 @@ export const createBunRouteHandler = (app: AnyElysia, route: InternalRoute) => {
119118
if (app.event.request?.length)
120119
fnLiteral += `const onRequest=app.event.request.map(x=>x.fn)\n`
121120

122-
fnLiteral += 'function map(request){'
121+
fnLiteral += `${app.event.request?.find(isAsync) ? 'async' : ''} function map(request){`
123122

124123
// inference.query require declaring const 'qi'
125124
if (hasTrace || inference.query || app.event.request?.length) {

0 commit comments

Comments
 (0)