Context type conflict with cloudflare-pages-plugin-trpc #116
Unanswered
juretopolak
asked this question in
Q&A
Replies: 2 comments
-
It looks like import { inferAsyncReturnType } from '@trpc/server'
import { drizzle } from 'drizzle-orm/d1';
import type { H3Event } from 'h3'
export interface Env {
DB: D1Database;
}
// TS Error in createContext ./server/api/trpc/[trpc].ts
// export const createContext = async (event: H3Event, env: Env) => {
export const createContext = async (event: H3Event) => {
const req = event.req
const res = event.res
//const db = drizzle(env.DB)
return { req, res};
};
export type Context = inferAsyncReturnType<typeof createContext>; All examples I've seen have any number of parameters in the Context function... is it normal that createContext in the createNuxtApiHandler can have only one parameter? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Interesting, I'll take a look and get back to you. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to set up Nuxt 3 with tRPC and Drizzle ORM / CloudFlare D1 Database and I'm stuck with the Context. Looks like the Context type in this module isn't "compatible" with
{ FetchCreateContextWithCloudflareEnvFnOptions } from 'cloudflare-pages-plugin-trpc'
.Is anyone willing to help me out with how to get this "stack" working? I'm kind of a newbie in TypeScript... 🙂
Demo project: https://github.com/juretopolak/trpc-nuxt
Beta Was this translation helpful? Give feedback.
All reactions