File tree Expand file tree Collapse file tree 4 files changed +17
-22
lines changed Expand file tree Collapse file tree 4 files changed +17
-22
lines changed Original file line number Diff line number Diff line change @@ -43,10 +43,10 @@ Libraries:
4343- [ preact-router] ( )
4444
4545If you need to host built assets with path rewriting,
46- I recommend ` hono-worker ` variant,
46+ check ` hono-worker ` variant,
4747or [ serve-handler] ( https://github.com/vercel/serve-handler ) ([ example] ( https://github.com/jokester/limb/blob/master/server/main.ts ) ).
4848
49- ### ` hono-worker ` , for edge-worker like environments
49+ ### ` hono ` , for node.js or edge servers
5050
5151- based on [ hono] ( https://github.com/honojs/hono )
5252- Capable of hosting SPA created by ` preact-spa `
@@ -84,6 +84,4 @@ The principles behind current (opinionated) settings are:
8484
8585## LICENSE
8686
87- - work from upstream repositories follows their licenses
88- - other contents are MIT licensed
89- - other contents are WTFPL licensed too
87+ - MIT
Original file line number Diff line number Diff line change 11import { Hono } from 'hono' ;
2- import { serve } from '@hono/node-server'
3- import debug from 'debug'
2+ import { serve } from '@hono/node-server' ;
3+ import debug from 'debug' ;
44
55debug . inspectOpts ! . depth = 100 ;
6- const logger = debug ( 'node-server' )
6+ const logger = debug ( 'node-server' ) ;
77
88const app = new Hono ( ) ;
99app . all ( '*' , async ( c ) => {
10- const reqUrl = c . req . raw . url
11- const headers = c . req . header ( )
12- const reqBody = await c . req . json ( ) . catch ( e => 'not json' )
13- logger ( { reqUrl, headers, reqBody } )
14- return c . text ( " It works!" )
15- } )
10+ const reqUrl = c . req . raw . url ;
11+ const headers = c . req . header ( ) ;
12+ const reqBody = await c . req . json ( ) . catch ( e => 'not json' ) ;
13+ logger ( { reqUrl, headers, reqBody} ) ;
14+ return c . text ( ' It works!' ) ;
15+ } ) ;
1616const server = serve ( app , ( info ) => {
17- console . log ( `Listening on http://localhost:${ info . port } ` ) // Listening on http://localhost:3000
18- } )
19-
20-
21-
17+ console . log ( `Listening on http://localhost:${ info . port } ` ) ; // Listening on http://localhost:3000
18+ } ) ;
Original file line number Diff line number Diff line change 1- name = " hono-worker"
2- compatibility_date = " 2023-01 -01"
1+ name = " hono-in- worker"
2+ compatibility_date = " 2024-11 -01"
33
44main = " ./src/app.ts"
55
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ cd $(dirname "$0")/..
66
77rm -rf package.json package-lock.json node_modules * /node_modules
88
9- for d in empty next preact-spa hono-worker ; do
9+ for d in empty next preact-spa hono; do
1010 tar xf $d .tar.xz
1111 pushd $d
1212 npm i
You can’t perform that action at this time.
0 commit comments