Serverless API with Cloudflare Workers (Hono, D1 & Drizzle ORM)

Поділитися
Вставка
  • Опубліковано 17 лис 2024

КОМЕНТАРІ • 64

  • @dova5944
    @dova5944 7 місяців тому +8

    Awesome video man, from the quality of this video I would have never guessed this is such a small channel. Keep up the good work!

    • @cdbrw
      @cdbrw  7 місяців тому

      Thanks your comment made my day 🙏 the goal is to make each video better than the last so hopefully its only up from here

  • @technoM4niac
    @technoM4niac 8 місяців тому +5

    Im glad to be early for the next big upcoming tech youtuber. Thanks for adding comments to your examples, helps to follow along 😎😎😎

    • @cdbrw
      @cdbrw  8 місяців тому

      Thanks, yea I figure I should add more comments to the videos 🤔

  • @juniorxInnovationAcademy
    @juniorxInnovationAcademy 6 місяців тому +2

    Im trying to build a multi-tenant inventory and small business records management system on Cloudflare. I really hope it doesnt let me down. Thanks for this video and the one you did after this adding in Lucia. They've been really helpful

  • @cas818028
    @cas818028 7 місяців тому +3

    That cold start was brutal

    • @cdbrw
      @cdbrw  7 місяців тому

      after the first deploy?

    • @journeyofc6200
      @journeyofc6200 5 місяців тому

      wtf are you talking about?

  • @ustav_o
    @ustav_o 6 місяців тому +3

    that might've been the best tutorial i've ever seen

    • @cdbrw
      @cdbrw  6 місяців тому

      thanks 🫶

  • @curious_abood
    @curious_abood 3 місяці тому

    Aboslute Beast, Since i have startred learning about cloudflare, i am just binge-watching your cloudflare content

    • @cdbrw
      @cdbrw  3 місяці тому

      This is awesome, thank you 🙏 have more cloudflare stuff on the way 😉

  • @VSIMadeIt
    @VSIMadeIt 7 місяців тому +2

    Intersted in seeing something like this with Turso instead of D1.

    • @cdbrw
      @cdbrw  7 місяців тому +1

      Noted, will work on the video soon 🫡

  • @rafamuttoni
    @rafamuttoni 7 місяців тому

    Great video, man! Thanks for making it.

    • @cdbrw
      @cdbrw  7 місяців тому

      Thanks for watching, glad you found it useful 🙏

  • @void-deus
    @void-deus 24 дні тому

    Dejo like , gracias compa , estaré siguiendo tu canal ,,espero mas material asi , me gusta como funciona todo este entorno , podrias mostrar como subir archivos etc ?

  • @yuhapps6758
    @yuhapps6758 3 місяці тому

    You are the man man man. I like you man. I like you a lot. Your video is exactly what I need right now. Oh my eyes are full of tears. Thank you so much.

    • @cdbrw
      @cdbrw  3 місяці тому +1

      🥹🥹

  • @rafalk0
    @rafalk0 7 місяців тому +1

    Awesome video! What's that VS Code db plugin you're using?

    • @cdbrw
      @cdbrw  7 місяців тому +1

      Thanks! Its just called "Database Client", I think its one of the more popular ones

  • @emilzonjeronimo8898
    @emilzonjeronimo8898 29 днів тому

    What about migrations in a CD pipeline? Handle the migrations manually with " bunx wrangler d1 execute --remote file= " does not seem to be the best approach. And the command provided by drizzle to apply migrations doesnt work because it doesnt use a DATABASE_URL variable.

  • @YouCan-wu2so
    @YouCan-wu2so 4 місяці тому

    Dude thank you!. Your video helped me solve an issue I had trying to use D1 locally.

  • @hardikpatel5286
    @hardikpatel5286 Місяць тому

    Awesome video. Thank you. I have a question.
    For every end point, i am create drizzle object. drizzle(c.env.DB). Is there any way to create drizzle object only at one place and reuse?

  • @tuannguyenanh7466
    @tuannguyenanh7466 22 дні тому

    Thank you so much

  • @hardikpatel5286
    @hardikpatel5286 Місяць тому

    Which database extension are you using to connect sqlite file?

  • @adityaparghi-j8e
    @adityaparghi-j8e Місяць тому

    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

  • @ayushrameja
    @ayushrameja 7 місяців тому

    Great video 🌟

    • @cdbrw
      @cdbrw  7 місяців тому

      thank you 🙏

  • @IkromAuliaFahdi
    @IkromAuliaFahdi 2 місяці тому

    have you create unit testing use hono? I have struggle with it

  • @flakybuild
    @flakybuild 6 місяців тому

    Great video 👌 Would you know a good way to run all of the pending migrations with drizzle in D1 so that one doesn't need to always explicitly specify them?

    • @cdbrw
      @cdbrw  6 місяців тому

      I've actually been thinking about this and maybe I'll make a video on it once I figure it out. Check out this GitHub thread: github.com/drizzle-team/drizzle-orm/discussions/1388
      I haven't tried the above so I can't say if it will work. The other idea I've been playing around with is using the bun shell to write a script which will execute each one by one. Will see if I can get anywhere with these 🤔

  • @jacobtb1
    @jacobtb1 7 місяців тому

    amazing vid, thanks

    • @cdbrw
      @cdbrw  7 місяців тому

      glad you found it useful 🙏

  • @DBDCheeto
    @DBDCheeto 6 місяців тому +1

    that was good

  • @juancarlosmamanirojas865
    @juancarlosmamanirojas865 4 місяці тому

    thanks for the video, What is the extension for database connection?

    • @cdbrw
      @cdbrw  4 місяці тому +1

      Its called "Database Client" by Weijan Chen

  • @illzcodes
    @illzcodes 7 місяців тому

    Have you figured out how to get drizzle studio to run? I keep getting an error even though my setup is exactly like this.

    • @cdbrw
      @cdbrw  7 місяців тому

      I'm still waiting for a better way to allow for this. Basically as of right now the only way to really do this is to split up your drizzle config into a local version and a cloudflare version but I'll wait on a more official implementation.
      If you're looking to get it working right now though, I recommend going through this thread and checking out the blog posts aswell: github.com/drizzle-team/drizzle-orm/discussions/1545

  • @4115steve
    @4115steve 7 місяців тому

    what other databases like d1 deploy to the edge? This seems like the best stack for a web app that uses edge with D1 and workers.

    • @cdbrw
      @cdbrw  7 місяців тому +1

      There’s also Turso for sqlite and Neon for postgres. I’m sure there’s other ones too. Check out the video I made on Turso if you’re interested 👀

  • @尀
    @尀 2 місяці тому

    which theme is this?

  • @samijuniorkahil7914
    @samijuniorkahil7914 8 місяців тому

    does drizzle create a new connection to the db on every request?

    • @cdbrw
      @cdbrw  8 місяців тому +1

      Since Cloudflare D1 is a serverless database, it doesn't require a persistent connection like a traditional database. You interact with it using HTTP-based APIs or through the D1 bindings available in Cloudflare Workers which eliminates the need for connection pooling and simplifies the handling of database operations.
      Drizzle just abstracts all these interactions for us and makes sure all operations are self-contained, without having to rely on persistent connections or stateful sessions.

    • @samijuniorkahil7914
      @samijuniorkahil7914 8 місяців тому

      @@cdbrw ah that makes sense

  • @IanMathaiya
    @IanMathaiya 6 місяців тому

    What are you using to highlight the errors like that 7:17?

    • @cdbrw
      @cdbrw  6 місяців тому

      Its a vscode extension called "Error Lens"

  • @2u841r
    @2u841r 2 місяці тому

    npm run db:generate
    This command is deprecated, please use updated 'generate' command (and a link)
    so you have to remove :sqlite (from generate:sqlite and up:sqlite from the file package.json)
    and add "dialect": "sqlite", in drizzle.config.json

    • @DudexChannel
      @DudexChannel Місяць тому

      create a drizzle.config.ts file with the content export default defineConfig({
      schema: "src/db/schema.ts",
      out: "drizzle/migrations",
      dialect: "sqlite", // "postgresql" | "mysql"
      dbCredentials: {
      url: ""
      },

    • @2u841r
      @2u841r Місяць тому +1

      @@DudexChannel yeah, that what i write in previous comment

  • @frazuppi4897
    @frazuppi4897 7 місяців тому

    how to have multiple routes in multiple files?

    • @cdbrw
      @cdbrw  7 місяців тому +1

      If let's say you had a `users` api and you wanted to split that up into its own router file, you would create it in lets say a users.ts file then create the router like so:
      const users = new Hono();
      You then add whatever routes you want to it and export users at the bottom of the file. Now in your main index.ts, all you have to do is just import users and then:
      const api = new Hono();
      api.route('/users', users);
      Hope this helps!

    • @frazuppi4897
      @frazuppi4897 7 місяців тому

      @@cdbrw Thank you so much :)

    • @roco9393
      @roco9393 4 місяці тому

      ​@@cdbrw I luv u 😘, excellent explanation

  • @PeterZhou-vi3ep
    @PeterZhou-vi3ep 7 місяців тому

    d1 is great, but it doesn't support transactions

    • @cdbrw
      @cdbrw  7 місяців тому +2

      Yea theres certain things like that where it shows its still very early days and not quite production ready yet but I still think overall it has the potential be really good

  • @iogilarb
    @iogilarb 6 місяців тому

    cloudflare?

    • @cdbrw
      @cdbrw  6 місяців тому

      cloudflare.

  • @patrickjreid
    @patrickjreid 5 місяців тому +1

    I got to say, with all the cloudflare news lately I would avoid anything they do with every fiber of my being.