Build a Serverless API (Cloudflare Workers, Drizzle ORM, Hono & Neon)

  Рет қаралды 13,312

Neon

Neon

Күн бұрын

Пікірлер: 16
@neondatabase
@neondatabase 7 ай бұрын
If you enjoyed watching this video, make sure to like and subscribe so you don't miss out on any future videos. Check out this video if you'd like to learn more about Neon database branching: kzbin.info/www/bejne/oGW5kp5qf5Zjgbc Drizzle ORM Docs: orm.drizzle.team/docs/overview Neon Serverless Driver: github.com/neondatabase/serverless
@tzuilee588
@tzuilee588 4 ай бұрын
Thank you for your clean explanation and taking the time to answer questions in comments below, its super helpful! 😁
@06_abdifatahdahir14
@06_abdifatahdahir14 6 ай бұрын
thank you for these information i wish you will made a video about how we can handle transactions
@neondatabase
@neondatabase 6 ай бұрын
If you would like to do interactive transactions, you can use the websocket version of the driver. Here's an example: github.com/neondatabase/serverless/tree/main?tab=readme-ov-file#example-nodejs-with-poolconnect - Mahmoud
@PlayerRPG85
@PlayerRPG85 6 ай бұрын
Subscribing because the host is a cool guy
@lifanhuang3181
@lifanhuang3181 3 ай бұрын
Hi, I have a suggestion with the Neon authorization 3rd party APPs part. I found that you authorized Cloudflare to read the Neon project, and then Cloudflare could fetch the DB password with such permissions. I think it's necessary to add a explicit hint at the authorization page, that the Read permission can see your DB password.
@yogyyconst
@yogyyconst 6 ай бұрын
do i need to write this every endpoint need query/insert to db? const client = new Client({ connectionString: c.env.DATABASE_URL }); const db = drizzle(client); await client.connect();
@neondatabase
@neondatabase 6 ай бұрын
Yes. In serverless environments such as Vercel Edge Functions or Cloudflare Workers, WebSocket connections can't outlive a single request. That means Pool or Client objects must be connected, used and closed within a single request handler. Don't create them outside a request handler; don't create them in one handler and try to reuse them in another; and to avoid exhausting available connections, don't forget to close them. Here's a code example github.com/neondatabase/serverless?tab=readme-ov-file#example-nodejs-with-poolconnect - Mahmoud
@yourlinuxguy
@yourlinuxguy 6 ай бұрын
Can you tell how to access the env vars outside the get method? I read the docs but couldn't understand.
@yogyyconst
@yogyyconst 6 ай бұрын
did you find out ?
@antonym00
@antonym00 6 ай бұрын
You can’t, because the server might be dead, and needs to start, so access is done in the method (if I understood the GitHub issue correctly)
@yourlinuxguy
@yourlinuxguy 6 ай бұрын
@@antonym00Yes, you're correct.
@saket37
@saket37 5 ай бұрын
What would be the right way to handle the db initialisation? Do I write the two lines in every single api single I need the env variables (since we are using hono)? Do I create the db in a middleware and then add that to hono context? What is the right way here?
@jamesfoley4426
@jamesfoley4426 Ай бұрын
Adding the db:generate command to package.json. I could not get the shortcut working that is demoed in the video I had to use drizzle-kit generate --dialect=postgresql --schema=./src/db/schema.ts just in case you run into the same issue great video tutorial
@marvinkr
@marvinkr 6 ай бұрын
So we can use this to connect to multiple frontend? (eg. NextJS web app, React Native mobile app)
@neondatabase
@neondatabase 6 ай бұрын
>connect to multiple frontend If you mean that different frontends can interact with the API, then yes. It's basically an API endpoint that any client can interact with - Mahmoud
Learn Drizzle ORM in 13 mins (crash course)
14:00
Neon
Рет қаралды 27 М.
This is why I love drizzle ORM
4:03
Web Dev Cody
Рет қаралды 13 М.
when you have plan B 😂
00:11
Andrey Grechka
Рет қаралды 62 МЛН
大家都拉出了什么#小丑 #shorts
00:35
好人小丑
Рет қаралды 95 МЛН
The NGINX Crash Course
50:53
Laith Academy
Рет қаралды 488 М.
Learn Cloudflare Workers 101 - Full Course for Beginners
1:00:04
Cloudflare Developers
Рет қаралды 56 М.
Drizzle vs Prisma: Which ORM is right for YOU?
5:59
Kodaps Academy
Рет қаралды 7 М.
【Cloudflare Workers】Hono+Cloudflare D1+Drizzle ORM 30分でREST APIを作成
25:07
TypeScriptでフルスタックエンジニアになる
Рет қаралды 1 М.
SSR Tailwind CSS with Hono JS on Cloudflare Workers #nobuild
24:29
Brayden Girard
Рет қаралды 4 М.
Complex Schema Design with Drizzle ORM | Common Patterns
45:55
I Stopped Using Express.js: Because Bun and Hono 🔥
10:23
Sam Meech-Ward
Рет қаралды 118 М.
Middleware & Authentication | Cloudflare Workers backend
44:16
when you have plan B 😂
00:11
Andrey Grechka
Рет қаралды 62 МЛН