0
0
mirror of https://github.com/honojs/hono.git synced 2024-11-25 13:19:30 +01:00
hono/runtime-tests/workerd/index.ts
Yusuke Wada dfbd717263
chore: rename runtime_tests to runtime-tests (#3419)
* chore: rename `runtime_tests` to `runtime-tests`

* fixed GitHub workflow
2024-09-17 14:51:43 +09:00

26 lines
521 B
TypeScript

import { upgradeWebSocket } from '../../src/adapter/cloudflare-workers'
import { env, getRuntimeKey } from '../../src/helper/adapter'
import { Hono } from '../../src/hono'
const app = new Hono()
app.get('/', (c) => c.text(`Hello from ${getRuntimeKey()}`))
app.get('/env', (c) => {
const { NAME } = env<{ NAME: string }>(c)
return c.text(NAME)
})
app.get(
'/ws',
upgradeWebSocket(() => {
return {
onMessage(event, ws) {
ws.send(event.data as string)
},
}
})
)
export default app