Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nesting hono routes returns undefined error #179

Open
TheDanBlanco opened this issue Sep 28, 2024 · 1 comment
Open

nesting hono routes returns undefined error #179

TheDanBlanco opened this issue Sep 28, 2024 · 1 comment

Comments

@TheDanBlanco
Copy link

TheDanBlanco commented Sep 28, 2024

Issue

using a route call on a fromHono chanfana proxy object returns TypeError: Cannot read properties of undefined (reading 'basePath')

Minimal reproduction code

import { fromHono } from "chanfana";
import { type Context, Hono } from "hono";

const app = new Hono();

const parent = fromHono(app);

const nested = new Hono();
nested.get("/", (c) => c.text("hello, world"));

const child = fromHono(nested);

parent.route("/nested", child);

export default parent;

Expected behavior

nesting chanfana proxies in a route function should produce the same results as when done in hono - that is, it should group the routes together as sub-routes

Additional Info

Chanfana version: 2.0.4

Relevant stack trace

TypeError: Cannot read properties of undefined (reading 'basePath')
    at route (/Users/db/dev/cloudflare/simple/node_modules/hono/dist/cjs/hono-base.js:111:25)
    at Proxy.<anonymous> (/Users/db/dev/cloudflare/simple/node_modules/chanfana/dist/index.js:763:50)

the proxy referred to at the trace is located here, and the route call in hono is located here.

there's also currently no documentation in chanfana on how to group hono routes together, only ittyrouter.

@TheDanBlanco TheDanBlanco changed the title grouping hono routes returns undefined error nesting hono routes returns undefined error Sep 28, 2024
@G4brym
Copy link
Member

G4brym commented Sep 30, 2024

Hey @TheDanBlanco sorry about that, this issue has been known internally since the release of 2.0.0
I just didn't have time yet to go around fixing that
But this is a top priority for the next version, hopefully coming up soon, i will keep posting updates here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants