P
Prisma5w ago
Abku

Prisma and Hono on Cloudflare Workers

Hello everyone, I am trying to connect with database using hono and prisma. Current Configs: .env
DATABASE_URL="postgresql://u:[email protected]/db-name?sslmode=require"
DATABASE_URL="postgresql://u:[email protected]/db-name?sslmode=require"
prisma.ts
import { Pool, neonConfig } from '@neondatabase/serverless'
import { PrismaNeon } from '@prisma/adapter-neon'
import { PrismaClient } from '@prisma/client'
import dotenv from 'dotenv'
import ws from 'ws'

dotenv.config()
neonConfig.webSocketConstructor = ws
const connectionString = `${process.env.DATABASE_URL}`

const pool = new Pool({ connectionString })
const adapter = new PrismaNeon(pool)
const prisma = new PrismaClient({ adapter })
export default prisma;
import { Pool, neonConfig } from '@neondatabase/serverless'
import { PrismaNeon } from '@prisma/adapter-neon'
import { PrismaClient } from '@prisma/client'
import dotenv from 'dotenv'
import ws from 'ws'

dotenv.config()
neonConfig.webSocketConstructor = ws
const connectionString = `${process.env.DATABASE_URL}`

const pool = new Pool({ connectionString })
const adapter = new PrismaNeon(pool)
const prisma = new PrismaClient({ adapter })
export default prisma;
prisma.schema
generator client {
provider = "prisma-client-js"
previewFeatures = ["driverAdapters"]
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model User {
email String @unique
name String
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["driverAdapters"]
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model User {
email String @unique
name String
}
index.ts
import { Hono } from 'hono';
import prisma from '../prisma/prisma';

const app = new Hono();

app.post('/:version', async (c) => {

const body = await c.req.json();
const version = c.req.param("version");

const newUser = await prisma.user.create({
data: {
name: body.name,
email: body.email,
},
});

return c.json(newUser);
});

export default app;
import { Hono } from 'hono';
import prisma from '../prisma/prisma';

const app = new Hono();

app.post('/:version', async (c) => {

const body = await c.req.json();
const version = c.req.param("version");

const newUser = await prisma.user.create({
data: {
name: body.name,
email: body.email,
},
});

return c.json(newUser);
});

export default app;
When I am sending a post request getting this kind of error. If you could please help.
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server