node-postgres uses crypto under the hood ?

Hello everyone, so I'm migrating from Prisma to Drizzle so I can use the NextJS's edge runtime I'm trying to make a query inside my edge middleware and I get the following error: The edge runtime does not support Node.js 'crypto' module. I'm using node-postgress as I've already mentioned What are my options here ?
10 Replies
Noahh
Noahhβ€’16mo ago
I don't run my stuff on the edge so I'm not positive it would work, but you could try https://github.com/porsager/postgres
GitHub
GitHub - porsager/postgres: Postgres.js - The Fastest full featured...
Postgres.js - The Fastest full featured PostgreSQL client for Node.js and Deno - GitHub - porsager/postgres: Postgres.js - The Fastest full featured PostgreSQL client for Node.js and Deno
Mr Volcano
Mr VolcanoOPβ€’16mo ago
Hmm, I guess it’s the only option.
How is it in general ? Run into any problems using it ?
Noahh
Noahhβ€’16mo ago
I haven't, the only downside is that Drizzle Studio doesn't support it as a driver yet, so if you plan on using Drizzle Studio you'll need to keep pg installed https://orm.drizzle.team/drizzle-studio/overview#prepare-config-file
rphlmr ⚑
rphlmr βš‘β€’16mo ago
postgres js has not yet published its fix to work with edge env 😦 https://discord.com/channels/1043890932593987624/1143421254678876271
Mr Volcano
Mr VolcanoOPβ€’16mo ago
I see. Thanks for the help Noah Thank you Raphael too for the headsup, will save me quite a bit of time!
rphlmr ⚑
rphlmr βš‘β€’16mo ago
Or it has πŸ€·β€β™‚οΈ https://github.com/porsager/postgres/pull/618 But last release is month ago πŸ₯Ά
Mr Volcano
Mr VolcanoOPβ€’16mo ago
Yeah.. that's unlucky What kind of solution did you go for ? I want to have middleware-like logic but without using the edge runtime.
I guess the paths are: 1. Create a custom middleware and therefore a custom server 2. Have your middleware call functions from other API routes that run on a normal nodeJS environment
Samuel Barnholdt
Samuel Barnholdtβ€’16mo ago
I'm trying to solve the same issue, and I believe using the neon driver should work here but I can't get that working locally
rphlmr ⚑
rphlmr βš‘β€’16mo ago
I would go for an API route yes. But I mainly use Remix, so, I didn't get deeper into nextjs middleware.
Mr Volcano
Mr VolcanoOPβ€’16mo ago
Makes sense, thanks you again Raphael πŸ™‚
Want results from more Discord servers?
Add your server