File tree Expand file tree Collapse file tree 3 files changed +17
-11
lines changed Expand file tree Collapse file tree 3 files changed +17
-11
lines changed Original file line number Diff line number Diff line change
1
+ import type { Context , Env } from 'hono' ;
2
+
3
+ import { unstable_getCustomContext } from '../../server.js' ;
4
+
5
+ // Internal context key
6
+ const HONO_CONTEXT = '__hono_context' ;
7
+
8
+ export const getHonoContext = < E extends Env = Env > ( ) => {
9
+ const c = unstable_getCustomContext ( ) [ HONO_CONTEXT ] ;
10
+ if ( ! c ) {
11
+ throw new Error ( 'Hono context is not available' ) ;
12
+ }
13
+ return c as Context < E > ;
14
+ } ;
Original file line number Diff line number Diff line change 1
- import type { Context , Env , MiddlewareHandler } from 'hono' ;
1
+ import type { MiddlewareHandler } from 'hono' ;
2
2
3
- import { unstable_getCustomContext } from '../../server.js' ;
4
3
import { resolveConfig } from '../config.js' ;
5
4
import type { HandlerContext , MiddlewareOptions } from '../middleware/types.js' ;
6
5
@@ -70,11 +69,3 @@ export const serverEngine = (options: MiddlewareOptions): MiddlewareHandler => {
70
69
await next ( ) ;
71
70
} ;
72
71
} ;
73
-
74
- export const getHonoContext = < E extends Env = Env > ( ) => {
75
- const c = unstable_getCustomContext ( ) [ HONO_CONTEXT ] ;
76
- if ( ! c ) {
77
- throw new Error ( 'Hono context is not available' ) ;
78
- }
79
- return c as Context < E > ;
80
- } ;
Original file line number Diff line number Diff line change 1
1
// These exports are for internal use only and subject to change without notice.
2
2
3
- export { serverEngine , getHonoContext } from './lib/hono/engine.js' ;
3
+ export { serverEngine } from './lib/hono/engine.js' ;
4
+ export { getHonoContext } from './lib/hono/ctx.js' ;
4
5
5
6
export const importHono = ( ) => import ( 'hono' ) ;
6
7
export const importHonoNodeServer : any = ( ) => import ( '@hono/node-server' ) ;
You can’t perform that action at this time.
0 commit comments