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;
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;
No description
2 Replies
SPS | Shootmail
SPS | ShootmailOP7mo ago
This was happening because one of my controller methods was not returning from all code paths. This is working now, but is this intended?
Nico
Nico7mo ago
Can you explain your solution more to see if thats’s how it’s intended to be
Want results from more Discord servers?
Add your server