Gathering detailed insights and metrics for @honojs/node-server
Gathering detailed insights and metrics for @honojs/node-server
Gathering detailed insights and metrics for @honojs/node-server
Gathering detailed insights and metrics for @honojs/node-server
npm install @honojs/node-server
Typescript
Module System
TypeScript (99.58%)
JavaScript (0.37%)
HTML (0.05%)
Total Downloads
3,104
Last Day
1
Last Week
3
Last Month
13
Last Year
378
405 Stars
192 Commits
48 Forks
5 Watching
2 Branches
37 Contributors
Minified
Minified + Gzipped
Latest Version
0.1.3
Package Id
@honojs/node-server@0.1.3
Unpacked Size
14.61 kB
Size
4.85 kB
File Count
18
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
200%
3
Compared to previous week
Last month
-18.8%
13
Compared to previous month
Last year
-77%
378
Compared to previous year
This project is still experimental.
This is HTTP Server for Hono on Node.js. Hono is ultrafast web framework for Cloudflare Workers, Deno, and Bun. It's not for Node.js. BUT, there may be a case that you really want to run on Node.js. This library is an adapter server that connects Hono and Node.js.
Hono is ultra fast, but not so fast on Node.js, because there is an overhead to adapt Hono's API to Node.js.
By the way, it is 2.x times faster than Express.
You can install from npm registry with npm
command:
npm install @honojs/node-server
Or use yarn
:
yarn add @honojs/node-server
Just import @honojs/node-server
at the top and write the code as usual.
The same code that runs on Cloudflare Workers, Deno, and Bun will work.
1import { serve } from '@honojs/node-server' // Write above `Hono` 2import { Hono } from 'hono' 3 4const app = new Hono() 5app.get('/', (c) => c.text('Hono meets Node.js')) 6 7serve(app)
For example, run it using ts-node
. Then an HTTP server will be launched. The default port is 3000
.
ts-node ./index.ts
Open http://localhost:3000
with your browser.
1serve({ 2 fetch: app.fetch, 3 port: 8787, // Port number, default is 3000 4})
Most built-in middleware also works with Node.js. Read the documentation and use the Middleware of your liking.
1import { serve } from '@honojs/node-server' 2import { Hono } from 'hono' 3import { prettyJSON } from 'hono/pretty-json' 4 5const app = new Hono() 6 7app.get('*', prettyJSON()) 8app.get('/', (c) => c.json({ 'Hono meets': 'Node.js' })) 9 10serve(app)
Use Serve Static Middleware that has been created for Node.js.
1import { serve, serveStatic } from '@honojs/node-server' 2 3//... 4 5app.use('/static/*', serveStatic({ root: './' }))
Yusuke Wada https://github.com/yusukebe
MIT
No vulnerabilities found.
No security vulnerabilities found.