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

  Рет қаралды 17,297

Neon

Neon

Күн бұрын

Пікірлер: 22
@neondatabase
@neondatabase 11 ай бұрын
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 8 ай бұрын
Thank you for your clean explanation and taking the time to answer questions in comments below, its super helpful! 😁
@06_abdifatahdahir14
@06_abdifatahdahir14 11 ай бұрын
thank you for these information i wish you will made a video about how we can handle transactions
@neondatabase
@neondatabase 10 ай бұрын
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
@Next-Js
@Next-Js Ай бұрын
Thank you, very good!
@sherhasan8896
@sherhasan8896 Ай бұрын
very helpful video thanks
@PlayerRPG85
@PlayerRPG85 10 ай бұрын
Subscribing because the host is a cool guy
@rawnato
@rawnato 2 ай бұрын
Hey man! Very nice video! I’m thinking to create some kind of project using CF! Can you share some ideas of costs that you have on CF! Just to have some knowledge about it! Another idea that can be a nice idea for a video, it’s a next-auth with this hono serverless api integration!
@yourlinuxguy
@yourlinuxguy 10 ай бұрын
Can you tell how to access the env vars outside the get method? I read the docs but couldn't understand.
@yogyyconst
@yogyyconst 10 ай бұрын
did you find out ?
@antonym00
@antonym00 10 ай бұрын
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 10 ай бұрын
@@antonym00Yes, you're correct.
@saket37
@saket37 9 ай бұрын
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?
@adityaparghi-j8e
@adityaparghi-j8e 3 ай бұрын
Hello can anyone please answer this, when i run npm create cloudflare --name and i select cloudflare workers , typescript, deploy no and when i go to vs code and run npm run dev it throws error errono -4095 i done everything uninstall Wrangler, install it again but it just doesn't work how can resolve this if anyone help
@yogyyconst
@yogyyconst 10 ай бұрын
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 10 ай бұрын
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
@marvinkr
@marvinkr 10 ай бұрын
So we can use this to connect to multiple frontend? (eg. NextJS web app, React Native mobile app)
@neondatabase
@neondatabase 10 ай бұрын
>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
@lifanhuang3181
@lifanhuang3181 7 ай бұрын
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.
@시
@시 Ай бұрын
hono, drizzle, and neon are good choices, but cloudflare workers should be careful. The 50ms computing time limit is too short for hashing and encryption tasks such as password hashing. on the other hand, aws lambda can use 15 minutes
@ElenaBG3
@ElenaBG3 16 күн бұрын
Serverless this, serverless that...
@jamesfoley4426
@jamesfoley4426 5 ай бұрын
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
Learn Drizzle ORM in 13 mins (crash course)
14:00
Neon
Рет қаралды 35 М.
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН
The Cloudflare Stack
13:26
Cloudflare Developers
Рет қаралды 22 М.
A Better Way to Write APIs?
12:00
Josh tried coding
Рет қаралды 100 М.
Cloudflare vs Vercel - We need to talk
27:50
Mehul - Codedamn
Рет қаралды 14 М.
Is Hono the holy grail of web frameworks?
18:33
AJ Stuyvenberg
Рет қаралды 14 М.
Complex Schema Design with Drizzle ORM | Common Patterns
45:55
The Perfect Dependency - SQLite Case Study
19:32
Tom Delalande
Рет қаралды 81 М.