Skip to content

Commit 3fe4772

Browse files
committed
🔧 fix literal handler when AOT is off
1 parent 9ab72e8 commit 3fe4772

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

‎src/dynamic-handle.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { TransformDecodeError } from '@sinclair/typebox/value'
2121

2222
// JIT Handler
2323
export type DynamicHandler = {
24-
handle: Handler<any, any>
24+
handle: unknown | Handler<any, any>
2525
content?: string
2626
hooks: LifeCycleStore
2727
validator?: SchemaValidator
@@ -332,7 +332,7 @@ export const createDynamicHandler =
332332
}
333333
}
334334

335-
let response = handle(context)
335+
let response = typeof handle === 'function' ? handle(context) : handle
336336
if (response instanceof Promise) response = await response
337337

338338
if (!hooks.afterHandle.length) {

‎test/core/dynamic.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ describe('Dynamic Mode', () => {
1313
expect(res).toBe('Hi')
1414
})
1515

16+
it('handle literal', async () => {
17+
const app = new Elysia({ aot: false }).get('/', 'Hi');
18+
19+
const response = await app.handle(req('/')).then((x) => x.text());
20+
21+
expect(response).toBe('Hi');
22+
})
23+
1624
it('handle body', async () => {
1725
const app = new Elysia({
1826
aot: false

0 commit comments

Comments
 (0)