0

So i was initializing the backend for my project using , Hono, Prisma , postgres and cloudfare workers as serverless backend. I am getting this error,

Ps : this is my index ts file

import { Hono } from 'hono'
import { PrismaClient } from '@prisma/client/edge'
import { withAccelerate } from '@prisma/extension-accelerate'
import { decode, sign, verify } from 'hono/jwt'


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

app.get('/', (c) => {

  return c.text('Hello Hono!')
})

app.post('/api/v1/signup',async (c)=>{
 const prisma= new PrismaClient({
    datasourceUrl: c.env.DATABASE_URL,

 }).$extends(withAccelerate());

 const body = await c.req.json();

 const user= await prisma.user.create({
    data: {
      email: body.email,
      password: body.password,
    }, 
 })
 const token = await sign({id: user.id}, "secret")
 return c.json({
  jwt: token
 })
  return c.text('Hello Hono!')
})

app.post('/api/v1/signin',(c)=>{
  return c.text('Hello Hono!')
})
app.post('/api/v1/blog',(c)=>{
  return c.text('Hello Hono!')
})
app.put('/api/v1/blog',(c)=>{
  return c.text('Hello Hono!')
})
app.get('/api/v1/blog/:id',(c)=>{
  return c.text('Hello Hono!')
})
export default app

This is my .env file

DATABASE_URL="postgres://avnadmin:[email protected]:15487/defaultdb?sslmode=require"

this is my wrangler.toml file

name = "backend"
main = "src/index.ts"
compatibility_date = "2024-12-05"

# compatibility_flags = [ "nodejs_compat" ]

# [vars] 

> ***(this is the mistake , i forgot to remove the #)***

DATABASE_URL="prisma://accelerate.prisma-data.net/?api_key=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcGlfa2V5IjoiOTMyMzExMjUtMDQ4My00YWE5LWI1ZjAtOTIxZmI2OWVhYmI0IiwidGVuYW50X2lkIjoiZjVjMTliZDllYjBlNjEyZjU4M2E0NjAwNzUwNDQ0MWIwMGJiYzRlODljZjllNTQ3NTVkNGU5MWMwMzEzMmM0MSIsImludGVybmFsX3NlY3JldCI6IjM4ZDc1NDFlLWQ2YTMtNDBlOS05YzA3LTY5MTk2ZTJkMzExYSJ9.C0jIpM8NfJB0PIh_UC0xLvpStJJTRnuOLmqUbh066CI"

this is my schema.prisma file

generator client {
  provider = "prisma-client-js"
}

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

model User {
  id       String  @id @default(uuid())
  email    String  @unique
  name     String?
  password String
  posts    Post[]
}

model Post {
  id        String  @id @default(uuid())
  title     String
  content   String
  published Boolean @default(false)
  authorId  String
  author    User    @relation(fields: [authorId], references: [id])
}

ps: ive ran npx prisma generate as well

sent this request using postman

but it is not working

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.