File tree Expand file tree Collapse file tree 3 files changed +44
-3
lines changed
Expand file tree Collapse file tree 3 files changed +44
-3
lines changed Original file line number Diff line number Diff line change 44 "description" : " Node.js Adapter for Hono" ,
55 "main" : " dist/index.js" ,
66 "types" : " dist/index.d.ts" ,
7+ "bin" : {
8+ "hono-node-server" : " ./dist/serve.js"
9+ },
710 "files" : [
811 " dist"
912 ],
Original file line number Diff line number Diff line change 1+ import { realpathSync } from 'node:fs'
2+ import { parseArgs } from 'node:util'
3+ import { serve } from './server'
4+
5+ const { values, positionals } = parseArgs ( {
6+ options : {
7+ port : { type : 'string' } ,
8+ } ,
9+ allowPositionals : true ,
10+ } )
11+
12+ if ( positionals . length === 0 ) {
13+ throw new Error ( 'Please specify the path to the app file.' )
14+ }
15+
16+ const appFilePath = realpathSync ( positionals [ 0 ] )
17+ import ( appFilePath ) . then ( ( { default : app } ) => {
18+ serve (
19+ {
20+ fetch : app . fetch ,
21+ port : values . port ? Number . parseInt ( values . port ) : undefined ,
22+ } ,
23+ ( info ) => {
24+ console . log ( `Listening on http://localhost:${ info . port } ` )
25+ }
26+ )
27+ } )
Original file line number Diff line number Diff line change 11import { defineConfig } from 'tsup'
2+ import type { Options } from 'tsup'
23
3- export default defineConfig ( {
4- entry : [ './src/**/*.ts' ] ,
4+ const options : Options = {
55 format : [ 'esm' , 'cjs' ] ,
66 dts : true ,
77 splitting : false ,
88 sourcemap : false ,
99 clean : true ,
10- } )
10+ }
11+ export default defineConfig ( [
12+ {
13+ entry : [ './src/**/*.ts' , '!./src/serve.ts' ] ,
14+ ...options ,
15+ } ,
16+ {
17+ entry : [ './src/serve.ts' ] ,
18+ ...options ,
19+ banner : { js : '#!/usr/bin/env node' } ,
20+ } ,
21+ ] )
You can’t perform that action at this time.
0 commit comments