fix: Updated app export for Hono RPC 5dcab22c
As reported in https://github.com/stevedylandev/bhvr/issues/12 the
client build fails if using the routes export pattern for hono. Still
remaining issue of fixing client type error.
Steve · 2025-05-10 20:45 1 file(s) · +7 −4
utils/templates.js +7 −4
6 6
7 7
app.use(cors())
8 8
9 -
const routes = app.get('/', (c) => {
9 +
app.get('/', (c) => {
10 10
  return c.text('Hello Hono!')
11 11
})
12 12
13 -
.get('/hello', async (c) => {
13 +
app.get('/hello', async (c) => {
14 14
15 15
  const data: ApiResponse = {
16 16
    message: "Hello BHVR!",
20 20
  return c.json(data, { status: 200 })
21 21
})
22 22
23 -
export type AppType = typeof routes
23 +
export type AppType = typeof app
24 24
export default app`;
25 25
26 26
export const tailwindTemplate = `import { useState } from 'react'
32 32
33 33
type ResponseType = Awaited<ReturnType<typeof client.hello.$get>>;
34 34
35 +
//@ts-ignore
35 36
const client = hc<AppType>(SERVER_URL);
36 37
37 38
function App() {
86 87
  )
87 88
}
88 89
89 -
export default App`
90 +
export default App`;
90 91
91 92
export const shadcnTemplate = `import { useState } from 'react'
92 93
import beaver from './assets/beaver.svg'
96 97
97 98
const SERVER_URL = import.meta.env.VITE_SERVER_URL || "http://localhost:3000"
98 99
100 +
//@ts-ignore
99 101
const client = hc<AppType>(SERVER_URL);
100 102
101 103
type ResponseType = Awaited<ReturnType<typeof client.hello.$get>>;
166 168
167 169
const SERVER_URL = import.meta.env.VITE_SERVER_URL || "http://localhost:3000"
168 170
171 +
//@ts-ignore
169 172
const client = hc<AppType>(SERVER_URL);
170 173
171 174
type ResponseType = Awaited<ReturnType<typeof client.hello.$get>>;