Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce Node.js handler #26

Merged
merged 8 commits into from
Nov 22, 2024
Merged

feat: introduce Node.js handler #26

merged 8 commits into from
Nov 22, 2024

Conversation

yusukebe
Copy link
Owner

@yusukebe yusukebe commented Nov 19, 2024

Fixes #25

This PR introduces a new handler for Node.js - hono-remix-adapter/node. You can use it to run your app on Node.js:

// main.ts
import { serve } from '@hono/node-server'
import { serveStatic } from '@hono/node-server/serve-static'
import handle from 'hono-remix-adapter/node'
import * as build from './build/server'
import { getLoadContext } from './load-context'
import server from './server'

server.use(
  serveStatic({
    root: './build/client',
  })
)

const handler = handle(build, server, { getLoadContext })

serve({ fetch: handler.fetch, port: 3010 })

To run the server, using tsx is easy way:

tsx main.ts

Or you can compile to a pure JavaScript file with esbuild with the command below:

esbuild main.ts --bundle --outfile=main.mjs --platform=node --target=node16.8 --format=esm --banner:js='import { createRequire as topLevelCreateRequire } from "module"; const require = topLevelCreateRequire(import.meta.url);'

@yusukebe yusukebe changed the title [WIP] feat: introduce Node.js handler feat: introduce Node.js handler Nov 21, 2024
@yusukebe yusukebe merged commit 4eec025 into main Nov 22, 2024
2 checks passed
@yusukebe yusukebe deleted the feat/node-handler branch November 22, 2024 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Question: Is this adapter supposed to work outside of Cloudflare?
1 participant