Elysia in Node.js
Usingtl;dr: Mount Elysia onto Hono and run using tsx
.
// app.ts
import { cors } from '@elysiajs/cors'
import { Elysia, t } from 'elysia'
import { serve } from '@hono/node-server'
import { Hono } from 'hono'
import { logger } from 'hono/logger'
const app = new Elysia().use(cors()).get('/', () => 'hi')
serve(
{
fetch: new Hono().use(logger()).mount('/', app.fetch),
port: +process.env.PORT || 3000,
},
(info) => {
console.log(`Listening on http://${info.address}:${info.port}`)
}
)
# Run the app
tsx app.ts
# Run the app in watch mode, restarting on file changes
tsx watch app.ts