Learning Ktor In 7 Days (server side Kotlin)

Sdílet
Vložit
  • čas přidán 25. 07. 2024
  • Join My Newsletter 👉 www.engel.dev/
    Learning Ktor in 7 days was not something I thought was possible, but to my surprise I was able to do it. For those unaware, ktor is an asynchronous framework for creating microservices, web applications, and APIs. This backend framework for Kotlin is fun, free, and open source. Basically if you are using Kotlin spring boot, you are doing it wrong. If you want to check out the finished project go to engel.dev
    🚶‍♂️ FOLLOW ME 🚶‍♂️
    Website - engel.dev
    Discord - / discord
    Twitter - / codyengeltweets
    Medium - / codyengel
    📝 DESCRIPTION 📝
    Ktor is a networking framework for Kotlin that allows you to build servers and clients. Ktor clients are multiplatform ready which allows sharing code between Android, iOS, and JavaScript, while we don't cover that in this video it is a really unique feature that is worth mentioning.
    If you are looking at how to become an expert in Ktor this video won't have all of the answers, although it will help you with getting started with Ktor.
    We start out by walking through the official tutorial for creating HTTP APIs with Ktor, followed by writing my first API to retrieve recent CZcams videos. I also take a detour to add Google Cloud Datastore as a light caching layer.
    On the third day I wanted to focus on how to run Ktor inside of a Docker container and in the span of 30 minutes I was doing just that. With a lot of extra time I decided to deploy Ktor to Google Cloud Run and also had the chance to use Google Cloud Build.
    The fourth day had me creating another API, this time it was for adding email addresses to my Mailchimp account. At this point I had to learn more about error handling with Ktor and also added some much needed instrumentation.
    The fifth and final day was deployment day. I packaged everything up and pushed it up to Google Cloud Run. I also deployed my static website to Google Cloud Storage and set up a load balancer to direct traffic correctly.
    📚 RESOURCES 📚
    Website - engel.dev
    Source Code - github.com/CodyEngel/EngelDev
    Creating HTTP APIs with Ktor - ktor.io/docs/creating-http-ap...
    Ktor with Docker - ktor.io/docs/docker.html
    Hosting a static website with Google Cloud Storage - cloud.google.com/storage/docs...
    Deploying container images to Google Cloud Run - cloud.google.com/run/docs/dep...
    ⏰ TIMESTAMPS ⏰
    0:00 - Intro
    0:45 - The Ktor HTTP APIs Tutorial
    4:12 - Recent CZcams Videos with Ktor
    7:32 - Running Ktor Inside of Docker
    9:38 - Email Marking with Ktor
    12:02 - Deploying Ktor to Google Cloud Run
    🎥 CAMERA GEAR 🎥
    Camera - amzn.to/2LM9Zt3
    Lens - amzn.to/3g0HING
    Microphone - amzn.to/37AAj2G
    Recorder - amzn.to/3lwCNVE
    Main Lights - amzn.to/3vUWRpw
    External Monitor - amzn.to/2YoM2Kl
    * Note: the above links are affiliate links.
    🖥 DESK GEAR 🖥
    Monitor - amzn.to/2yjZPqR
    Headphones - amzn.to/2YBuo68
    MacBook Pro 2019 - amzn.to/30YyuXy
    * Note: the above links are affiliate links.
    Try Epidemic Sound: www.epidemicsound.com/referra...
    #softwareengineer #softwaredeveloper

Komentáře • 52

  • @CodyEngelCodes
    @CodyEngelCodes  Před 3 lety +7

    What service are you going to build with ktor?

    • @Basirafeef
      @Basirafeef Před rokem +1

      hello sir, i have a basic app requirements to create an app that work in all platforms, the app must work offline and the data is backup time to time to the cloud.
      Sir i am thanking to create an android app with kotlin and ktor to create server and client in the same app and create ktor server to serve the server and web client for other platforms that are connected to the same local network to access the server with local ip address.
      My question is, is it possible to host kotlin web server from android that serve the same sqlite database and other resources that android app uses?
      Please help to start my project.
      thanks.

    • @erdemserhat
      @erdemserhat Před 5 měsíci

      @@Basirafeef everything you mentioned is possible, even easier with ktor

  • @edboss36
    @edboss36 Před 8 měsíci

    This is the best programming video I've seen on youtube. You explained your thought process and how to follow tutorials the right way. I was actually trying to find videos like yours where an expert shares their real experience instead of giving general advice so thanks

  • @DorianDevelops
    @DorianDevelops Před 3 lety +6

    Great video!!! It's been a while since I've done anything with Kotlin. Might have to check out ktor!

    • @CodyEngelCodes
      @CodyEngelCodes  Před 3 lety +2

      Thanks Dorian. Ktor is pretty awesome, I was learning Golang for service development but I think ktor fits the bill for most things now. Startup time is the only downside, I’d probably still use Go for a service that I want to scale up and down relatively quickly

  • @timurodintsev2832
    @timurodintsev2832 Před 3 lety

    Loved ur video. Thx man! Good luck in future!

    • @CodyEngelCodes
      @CodyEngelCodes  Před 3 lety

      Thank you for the words of encouragement Timur :)

  • @hinocenciopaulo
    @hinocenciopaulo Před 2 lety

    Pretty good video my man, thanks for that. You just got a new subscriber.

  • @kennygunderman
    @kennygunderman Před 3 lety +3

    4:10 AYO DATS ME. But for real, this is insane quality 👀 nicely done my man

  • @chadmalla
    @chadmalla Před 2 lety +1

    Hi Cody, great quality videos! Next video, if not already made, is tips on the path of SDE 1 to senior like what you should be doing at work and off-work, habits, etc.

  • @danielhmorgan
    @danielhmorgan Před 3 lety

    Nice. Loved the fast tempo.

    • @CodyEngelCodes
      @CodyEngelCodes  Před 3 lety

      Thanks Danny, I tried to make it a bit quicker so happy it worked ☺️

  • @murlikrishnat29
    @murlikrishnat29 Před 3 lety

    Great video...How do we create preflight request? Can you elaborate more on how to handle CORS in ktor?

  • @tunisiaFANS
    @tunisiaFANS Před 3 lety

    Thanks for the video man ❤️✌️
    How is ktor so far? Did you use any kind of user authentification in your server?
    Hope you do more videos like this one ✌️✌️

  • @DaveJacobseniOS
    @DaveJacobseniOS Před 3 lety

    Beast!

  • @kyleMcBurnett
    @kyleMcBurnett Před rokem

    Thanks for the inspiration.

    • @CodyEngelCodes
      @CodyEngelCodes  Před rokem

      Kyle thank you so much for the super thanks! I've been taking a bit of a break from CZcams as there has been some personal stuff going on but please feel free to drop by the Discord if you haven't already. 🙇‍♂️

  • @mohamedelsayed8428
    @mohamedelsayed8428 Před 3 lety

    while creating container it gives me this error
    Failed to deploy ' Dockerfile: Dockerfile': Can't retrieve image ID from build stream

  • @MateuszPerlak
    @MateuszPerlak Před 3 lety

    Couple thing I added to my Ktor environments is Koin for DI and JetBrains - Exposed Framework for Database connection.
    Kotlin makes is so easy to integrate all of it.
    Also couple added extension methods make it easy to read path's parameter values or query values.

    • @CodyEngelCodes
      @CodyEngelCodes  Před 3 lety

      Nice! Dependency injection is on my todo list, I was probably going with Dagger but still need a better feel for what they might look like.

    • @MateuszPerlak
      @MateuszPerlak Před 3 lety +1

      @@CodyEngelCodes I found it Koin to be easier to understand and use.

  • @brianevans4
    @brianevans4 Před 2 lety

    Very nice video. I tried to learn ktor yesterday, and after 6 failed attempts, I almost gave up. Just kept running into errors that I couldn't seem to solve. Gonna give it another try after watching this video

  • @PostMeridianLyf
    @PostMeridianLyf Před 2 lety

    Thank you for this run down. Gives me some hope lol

  • @Basirafeef
    @Basirafeef Před rokem

    hello sir, i have a basic app requirements to create an app that work in all platforms, the app must work offline and the data is backup time to time to the cloud.
    Sir i am thanking to create an android app with kotlin and ktor to create server and client in the same app and create ktor server to serve the server and web client for other platforms that are connected to the same local network to access the server with local ip address.
    My question is, is it possible to host kotlin web server from android that serve the same sqlite database and other resources that android app uses?
    Please help to start my project.
    thanks.

  • @kawshiqahmed6395
    @kawshiqahmed6395 Před 3 lety

    There have a specific plugin for ktor in intellij idea.

  • @DevlogBill
    @DevlogBill Před rokem

    Hi Cody, I played around with Kotlin and I fell in love with the language. It is strongly typed and it feels like JavaScript for some reason. But for the past 3 months I've been using Django for my backend. I've been thinking about learning Ktor because I am interested in Android Development with Kotlin. To be honest Ktor sounds more complicated than Django. I was thinking are you able to create an Android app with Kotlin and Android Studio and afterwards create the API with Django for an Android project? Or would you recommend learning Ktor for Android Development? Thanks.

    • @CodyEngelCodes
      @CodyEngelCodes  Před rokem

      If Django suits your needs then by all means make use of it. There's no need to use ktor for an Android project, there are some benefits with code reuse and such but doesn't make sense if it'll over complicate your project.

    • @DevlogBill
      @DevlogBill Před rokem

      @@CodyEngelCodes I never used another back end library or framework before Django is my first. So far I noticed if you learn the Django way of doing things it is not so complicated. I haven't reached this point yet for my project but I think the hardest part is introducing your API to you're Android app. I guess I will figure that out once I reach that point.
      But thanks for sharing you're thoughts on Ktor looks interested but more complicated than Django.

  • @scienceschool4998
    @scienceschool4998 Před 2 lety

    How can I access my API from anywhere on the web except on my localhost?

    • @CodyEngelCodes
      @CodyEngelCodes  Před 2 lety

      Deploy it to a server, check out my video on GitHub Actions because that's where I set up a CI pipeline to deploy my API automatically to Google Cloud.

  • @storypur
    @storypur Před 2 lety

    Is Ktor and Kotlin good to develop large-scale android application?

    • @CodyEngelCodes
      @CodyEngelCodes  Před 2 lety

      I haven't used ktor in an Android application but I don't see why you couldn't. Kotlin is definitely the way to go for modern Android development though.

  • @libintantony
    @libintantony Před 2 lety

    Can u explain how to handle refresh token in ktor???

    • @CodyEngelCodes
      @CodyEngelCodes  Před 2 lety

      I'd recommend checking out the authentication and authorization section on the ktor docs: ktor.io/docs/auth.html#bearer

  • @MrRahulmalik
    @MrRahulmalik Před 3 lety

    can you make a video on creating a project using ktor and kotlin

    • @CodyEngelCodes
      @CodyEngelCodes  Před 3 lety +2

      I can try to get around to it. I do want to have a dedicated ktor course in the future.

    • @MrRahulmalik
      @MrRahulmalik Před 3 lety

      @@CodyEngelCodes Awesome!

  • @davidconnelly
    @davidconnelly Před 2 lety +2

    Okay. Very interesting. Great video. Your skills are awesome. Here are a couple of comments that spring to mind: I think Kotlin is well positioned to become a very popular general purpose language that could be used for pretty much anything. This is definitely one to watch. Second point: I see this implementation of Kotlin as being in direct competition to something like NodeJS. Finally, the demo was incredibly impressive for sure. However, there are two things that would stop me from jumping in with KTOR; 1). I would have concerns about it potentially having a shortage of libraries (I'm sure that won't always be the case). 2). Reverting to VueJS seems like a step backwards to me. The 'javascript-type' websites are commercially weak because they tend to perform poorly on search engines. Actually, I think that it's a sort of out-dated way to do web development. Nevertheless, I do want to stress that I'm super impressed by what you've done here. I'd like to see KTor doing well. It looks very interesting indeed. Cheers!

    • @CodyEngelCodes
      @CodyEngelCodes  Před 2 lety

      Thanks David! I'll have to investigate options to avoid using VueJS, I've been trying to avoid ReactJS but maybe it's time for me to just suck it up and learn it 😅

  • @camo5768
    @camo5768 Před 2 lety

    how can i self host this?

    • @CodyEngelCodes
      @CodyEngelCodes  Před 2 lety

      You could use a service like DynDNS on a home server and then point your domain there.

  • @renascienza.bazarclub
    @renascienza.bazarclub Před 2 lety

    I learned Ktor in about two days, and Javalin in just one day, and applied in projects immediately. Is not a steep learning curve.

  • @hamuelagulto796
    @hamuelagulto796 Před 3 měsíci

    7 days seems long. you can learn it in a day

    • @kafka5973
      @kafka5973 Před 23 dny

      hey can u please suggest me how and from where I can learn ktor framework for a beginner like me?