App breaks in RPC mode, works normally

Hi, as soon as I export the AppType as mentioned in the docs. I start getting this error. If I do not export the AppType and do the normal export default app;, app works fine here is my
index.ts


import { Context, Hono } from 'hono'
import { secureHeaders } from 'hono/secure-headers'
import { Bindings } from './bindings';
import authController from './controllers/auth-controller';
import { initDb } from './db';
import { jwt } from 'hono/jwt'
import templateController from './controllers/template-controller';

const app = new Hono();
app.use(secureHeaders());

app.use("*", async (c: Context<Bindings>, next)=>{
    const db = initDb(c);
    c.set("db", db);
    await next();
});

app.use('/api/auth/test', (c: Context<Bindings>, next) => {
    const jwtMiddleware = jwt({
      secret: c.env.JWT_SECRET,
      cookie: "token"
    })
    return jwtMiddleware(c, next)
});

const router = app.route('/api/auth', authController).route('/api/template', templateController);

export default app;
export type AppType = typeof router;
image.png
Was this page helpful?