has anybody set up a next-pages app with D1 & Prisma? would love to see how you set up a basic route
has anybody set up a next-pages app with D1 & Prisma? would love to see how you set up a basic route to read the request.env because i cant at all





./functions API endpoints.Cannot find module '@prisma/client'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?ts(2792)npx wrangler devnpx wrangler pages dev .vercel/output/static --compatibility-flags="nodejs_compat" --port 8788npx wrangler pages dev but I think that makes no difference...wrangler.toml look?dev env, fwiwnpx wrangler d1 execute audition --command "SELECT * FROM _some_table_;" --local does that work?/favicon.ico_routes.json like: _routes is Pages specific, not for Workers generically, but yesgetRequestContext for next on pages, idk how you haven't stumbled upon itgetRequestContext is for prod environment specifically, but it also should work on local if im not mistaken.env getRequestContext().env and couple of other cloudflare related things, such as city and country of the request origin23:08:22.672 Using v2 root directory strategy
23:08:22.696 Success: Finished cloning repository files
23:08:24.728 wrangler.toml config file detected
23:08:25.838 Failed: an internal error occurred. If this continues, contact support: https://cfl.re/3WgEyrH./functionsThen configure the runtime types by creating a functions/tsconfig.json file:
functions/tsconfig.json
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"lib": ["esnext"],
"types": ["@cloudflare/workers-types"]
}
}
If you already have a tsconfig.json at the root of your project, you may wish to explicitly exclude the /functions directory to avoid conflicts. To exclude the /functions directory:
tsconfig.json
{
"include": ["src/**/*"],
"exclude": ["functions/**/*"],
"compilerOptions": {
}
}import { PrismaClient } from '@prisma/client';
import { PrismaD1 } from '@prisma/adapter-d1';Cannot find module '@prisma/client'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?ts(2792)npx wrangler devimport { PrismaClient } from '@prisma/client';
import { PrismaD1 } from '@prisma/adapter-d1';
export const onRequestGet: PagesFunction<Env> = async (context) => {
const adapter = new PrismaD1(context.env.DB)
const prisma = new PrismaClient({ adapter })npx wrangler pages dev .vercel/output/static --compatibility-flags="nodejs_compat" --port 8788npx wrangler pages devdevnpx wrangler d1 execute audition --command "SELECT * FROM _some_table_;" --local/favicon.ico_routes.json{
"version": 1,
"include": ["/api/*"],
"exclude": ["/*.*"]
}_routesgetRequestContextgetRequestContextgetRequestContext().envconst url = new URL(request.url);
if (url.pathname === '/something') {
// do your work
}