Tiebienotjuh
Tiebienotjuh
HHono
Created by Tiebienotjuh on 11/8/2024 in #help
Strange error
Hi, I'm trying to create something with HonoJS, CloudFlare Workers and D1 (with Prisma). I just want to temporarily lock the user, only I run into this strange problem. Code:
import { Hono } from "hono";
import { logger } from 'hono/logger'

import { fromHono } from "chanfana";
import { EventCreate } from "routes/event/EventCreate";

type Bindings = {
DB: D1Database
}

const app = new Hono<{ Bindings: Bindings }>();

app.use(logger())

app.use(async (c, next) => {
c.user = { id: 1 }
await next();
}
)

const openapi = fromHono(app, {
docs_url: "/docs",
});

openapi.post("/api/event", EventCreate);

export default app;
import { Hono } from "hono";
import { logger } from 'hono/logger'

import { fromHono } from "chanfana";
import { EventCreate } from "routes/event/EventCreate";

type Bindings = {
DB: D1Database
}

const app = new Hono<{ Bindings: Bindings }>();

app.use(logger())

app.use(async (c, next) => {
c.user = { id: 1 }
await next();
}
)

const openapi = fromHono(app, {
docs_url: "/docs",
});

openapi.post("/api/event", EventCreate);

export default app;
Error that vsc shows: Property 'user' does not exist on type 'Context<{ Bindings: Bindings; }, never, {}>'.ts(2339) Thanks for any help!
3 replies