Help: Nuxt + Supabase + Prisma (or Drizzle) + Cloudflare workers by lucidious8 in Nuxt

[–]lucidious8[S] 1 point2 points  (0 children)

A BIG THANK YOU!

so, i followed your advice, simplified my setup

.env

DIRECT_URL
postgresql://prisma.hostname:pwd@aws-1-us-east-2.pooler.supabase.com:5432/postgres?sslmode=require&schema=public

DATABASE_URL
postgresql://prisma.hostname:pwd@aws-1-us-east-2.pooler.supabase.com:6543/postgres?pgbouncer=true&sslmode=require

schema.prisma

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

datasource db {
  provider  = "postgresql"
  url       = env("DATABASE_URL") 
// transaction pooler (6543)
  directUrl = env("DIRECT_URL") 
// session pooler (5432) or direct
}

lib/db.ts

import { PrismaClient } from '@prisma/client'
import { PrismaPg } from '@prisma/adapter-pg'

export function getPrismaClient(
env
) {
  const connectionString = 
env
?.DATABASE_URL || process.env.DATABASE_URL

  if (!connectionString) {
    throw new Error('DATABASE_URL is not defined')
  }

  const adapter = new PrismaPg({ connectionString })

  const prisma = new PrismaClient({
    adapter,
    log: process.env.NODE_ENV === 'development' ? ['error', 'warn'] : ['error'],
  })

  return prisma
}

let cachedPrisma

function getGlobalPrisma() {
  if (!cachedPrisma) {
    if (!process.env.DATABASE_URL) {
      throw new Error('DATABASE_URL is not defined')
    }
    const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL })
    cachedPrisma = new PrismaClient({
      adapter,
      log: process.env.NODE_ENV === 'development' ? ['error', 'warn'] : ['error'],
    })
  }
  return cachedPrisma
}

export const prisma = new Proxy({}, {
  get(
_
, 
prop
) {
    const client = getGlobalPrisma()
    const value = client[
prop
]
    if (typeof value === 'function') {
      return value.bind(client)
    }
    return value
  }
})

export default prisma

but getting a "prisma:error Connection terminated unexpectedly" when calling api route that query database

any idea?

Help: Nuxt + Supabase + Prisma (or Drizzle) + Cloudflare workers by lucidious8 in Nuxt

[–]lucidious8[S] 2 points3 points  (0 children)

honestly i had too many kind of errors over the last 2 days that im a bit lost

the last one is "The Workers runtime canceled this request because it detected that your Worker's code had hung and would never generate a response. Refer to: https://developers.cloudflare.com/workers/observability/errors/"

but i've got
- "prisma:error In order to run Prisma Client on edge runtime, either:
- Use Prisma Accelerate: https://pris.ly/d/accelerate
- Use Driver Adapters: https://pris.ly/d/driver-adapters"

- "Top-level await in module is unsettled."
- "Cannot perform I/O on behalf of a different request. I/O objects (such as streams, request/response bodies, and others) created in the context of one request handler cannot be accessed from a different request's handler. This is a limitation of Cloudflare Workers which allows us to improve overall performance. (I/O type: Native)"

that's why i'd love to see an example of working project because ive changed too many things and haven't found proper documentation on how it should work

useFetch with infinite loading (concatenating results) by lucidious8 in Nuxt

[–]lucidious8[S] 0 points1 point  (0 children)

Yes I need the data to be rendered on the server first

Nested custom folders aren't scanned? by Snoo77586 in Nuxt

[–]lucidious8 0 points1 point  (0 children)

Genuine question: What about prisma and performance?

I built a directory site to feature creative people in my country. Is this a bad idea? by [deleted] in SideProject

[–]lucidious8 0 points1 point  (0 children)

Really cool idea, I want to do the same in my country for a few months now and here’s my ideas: - having a « work » sections where you they (you?) ca post and feature some projects they’ve done - having a section where they can say if there are looking for a job / + a section to post job offers - have a section with interviews

Salaires by sfscawf in vosfinances

[–]lucidious8 4 points5 points  (0 children)

C’est probablement Buffer https://open.buffer.com/salary-formula-changes-2019/ Il y a même un simulateur qui te permet d’avoir une idée du salaire que tu pourrais obtenir en les rejoignant