Build a CRUD API with TypeScript, Express, MongoDB, Zod and Jest

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

КОМЕНТАРІ • 67

  • @angelhdzdev
    @angelhdzdev 2 роки тому +18

    My mind is blown. So much useful material discussed in this video. A topic that at first sight looks complicated but you made it look as a piece of cake. I was needing this because i have been recording vids about Vue, Nest, Nuxt, TypeScript, but been avoiding the e2e and unit tests topics. Now i feel confident to start adding them to my projects. Appreciate a lot your charisma and patience. Wishing you health and success.

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

    I learn so much extra stuff everytime i see your livestream. Thanks.

  • @wintoniw703
    @wintoniw703 2 роки тому +1

    You're so advanced, CJ! Also, your effort in sharing in-demand knowledge is immense! Bless your heart!

  • @atraps7882
    @atraps7882 2 роки тому +1

    Ive written several backend APIs with express and plain JS but im looking more into TS nowadays for reasons like clean-er architecture and improving code quality by having a more structured and predictable behavior using types. This tutorial allowed me to bridge my existing knowledge of building RESTful APIs in node+express with TypeScript magic. Thank you Mr. CJ

  • @vickyvirat5166
    @vickyvirat5166 Рік тому

    I looked for an express tutorial with the MongoDB driver but not found any proper tutorial (mostly found with mongoose library). This one is awesome as it not only shows the proper usage of MongoDB driver with zod and typescript. Great video🙏

  • @koti1217
    @koti1217 Рік тому

    I saw you on twitch a long time ago, but I didn't remember your name.
    So glad I found you again, exactly at the right time :)
    Keep up the work you do, I really appreaciate it!

  • @TheUltimateGeminiHasSurvived

    Keep up the great work! I used to be active in your Discord. I love how respectful you are! Awesome work, Cody!!

  • @AJax2012
    @AJax2012 2 роки тому +5

    Great video! Question though - you said in your video that you would create a link to a config loader video, but I don't see one? Maybe I'm missing something, but you mention it at around 00:27:00 I'm interested in seeing how you would create one - the only place I have ever actually seen one in JS/TS is Nest.js, I think. It definitely sounds like it would be more convenient than depending on process.env every time I need to get a configuration variable, haha. Only thing that really comes to mind though is some sort of a static variables file...

  • @sunman108
    @sunman108 Рік тому

    Amazing tutorial! thank you very much. I love your chilled style of coding. Hello to Colorado!

  • @_rushikesh_ganesh
    @_rushikesh_ganesh 2 роки тому

    Your lifesaver!! Recently I was working on an express + typescript project I didn't find that much content for it 🙏

  • @alexliebhaber3109
    @alexliebhaber3109 Рік тому

    So glad I ran into this video! Wanting to move towards using typescript and this and your intro video are toooo good. Thank you so much for the effort! Not sure if you plan on doing more content about testing and/or jest, but I would really enjoying learning more about it from you

  • @andianwar5784
    @andianwar5784 2 роки тому +1

    your video so relaxing and soothing for an educational tutorial video, man!
    I love it so much!
    Keep it up, okay? i know viewer may have high hope for you, but don't let it burden you, just keep it up!

  • @zlatkoiliev8927
    @zlatkoiliev8927 2 роки тому +1

    So so happy I have subscribed to your channel!!! I have learned really a TON thanks to your vids!

  • @dannorcott773
    @dannorcott773 Рік тому +1

    Great bloke, great video, great all round! Thanks CJ, helped me a lot.

  • @daninmanchester
    @daninmanchester Рік тому +1

    Great video. I already have an MVC app with objects and it doesn't use ZOD. I am curious how easily ZOD can be applied to existing objects without redefining everything.

  • @MistaT44
    @MistaT44 2 роки тому +3

    Great stuff as always, thanks CJ!

  • @ryan_roga
    @ryan_roga 2 роки тому

    26:59 is still missing a link. How do I do this config loader? I think that would make a really good short. I couldn't find a video by you using those search terms. Would love to know how, though!

    • @CodingGarden
      @CodingGarden  2 роки тому +1

      I think I worked on this during a fresh spots stream, so it would be on the archive channel. You can see the example here: github.com/CodingGarden/fresh-spots/blob/main/app/utils/config.ts
      Remind me next time I'm streaming and I will try to make a video on it.
      There is also this library I've used before: www.npmjs.com/package/config

    • @ryan_roga
      @ryan_roga 2 роки тому

      @@CodingGarden Thanks, CJ. I'll have a look for that video.

  • @cinegolpo-movieexplainedin8192

    my vs code ts server is very slow. when i am working, any idea how to improve the performance.
    my PC has 32 gb ram

  • @Luke-Barrett
    @Luke-Barrett 4 місяці тому

    With the latest version of nodemon you don't need to install ts-node separately.

  • @vivuuc4209
    @vivuuc4209 Рік тому

    what is name of theme extension you use?

  • @tabliqatchi6696
    @tabliqatchi6696 Рік тому

    This is outstanding! 🌠🌠🌠🌠🌠 You're such a GREAT instructor, I think I've discovered you late! This is the second video I'm seeing from your channel and this is all amazing!
    Please also do the follow-up video 😭😭😭😭😭
    One small recommendation: In a follow-up video "before adding a client", do a refactoring video on all this code once again so that it's as close as possible to a production-ready API and deploy it! Also there are parts in this video that you've said "let's not do that for now", those are good topics as well to talk about and add improvements!
    Thank you CJ! 💖💚💛

  • @kraldragon1324
    @kraldragon1324 Рік тому

    this is what i am searching. Thanks for sharing

  • @bruhgoaway4876
    @bruhgoaway4876 2 роки тому +1

    Hi, could anyone provide me some clarity on an issue I'm facing? I'm performing the POST req test which is supposed to expect a 422 error (~57:00). However, my request doesn't yield this 422 error, and instead creates the post. After playing around with the Todo schema, I noticed that no matter what I set the content as, the Todo still get validated and pushed to Mongo. I can even add an integer or null into the content field, and the data still gets pushed to Mongo. The only place the "content" prop appears is in test files and the todos.model.ts file. Could anyone give me some insight as to what's going on here?
    P.S. Great video Coding Garden! Regardless of this error, I still learned a lot, and you provide a lot of useful resources and gave insight that helped clarify many other questions I had throughout the video.
    UPDATE: I solved the issue minutes after posting this. I was checking out the Github repo for a solution, and had removed this line from the createOne() function: const validateResult = await Todo.parseAsync(req.body);
    I was wondering why this line wasn't in the final version of the code, but then also realized it was refactored into the validateRequest middleware.

    • @CodingGarden
      @CodingGarden  2 роки тому +1

      Glad you figured it out! The indirection to the middleware can definitely be a bit confusing if you're looking at the handlers file only.

    • @bruhgoaway4876
      @bruhgoaway4876 2 роки тому

      @@CodingGarden I appreciate it. Also, just a possible future video suggestion, but I really liked how you displayed the process of writing tests and resolving failures. The way you utilized the result of a POST request to test retrieving a single ID was really smart, yet not a tactic I've seen in other Jest videos. Additionally, you seem to understand Jest configurations really well, which is something that's hard to grasp/find better explanations of when using just the docs and info from blogs.
      Regardless though, you did a really good job at covering all the tools you put in the title 👍

  • @abw21701
    @abw21701 2 роки тому

    Quick question: I've seen advice about getting into coding. One thing I found is that is suggested that I just get a job in coding - basically get paid to learn - Does that make sense to you? Is that how you got started?

  • @vittorio9449
    @vittorio9449 2 роки тому +1

    Hey CJ I just want to tell you that you're great. I love your videos and you're really an inspiring person. Love the way you explain things and help people to understand better. I wish you always the best, and that you can continue in this way
    P.S
    I didn't see on your Twitch channel the live about nuxt 3, regarding the new framework you will use for the next Friday project. Will you upload it here on UA-cam? Thanks so much

  • @tusharjaiswal3133
    @tusharjaiswal3133 11 місяців тому

    Shall we not mock the DB instead of making actual calls to DB while writing test cases? WE may lose actual data if the db.drop( ) runs also DB calls will have a cost and impact the overall costing whenever the tests are run.

  • @Thinna
    @Thinna 2 роки тому

    Hi CJ, your content is really helpful. I really learnt a lot.
    I have a small question to ask How can I handle the "Promise returned in function argument where a void return was expected."? When you send the findAll as async function in typescript it gives a warning because of promise void.
    Because in router .get it won't accept promise void functions. One solution I came across is to use async function in side find all method.
    But in this case we have to use in every function in the handler. Is there a better approach ?
    Thank you

    • @evliyacelebifi
      @evliyacelebifi 11 місяців тому

      Have you found any better solution?

  • @saminyasar004
    @saminyasar004 2 роки тому

    Great video. Thank you very much, CJ. Take love💚

  • @VictorvictorRamos
    @VictorvictorRamos Рік тому

    Does somebody knows where's the next part of this video?

    • @CodingGarden
      @CodingGarden  Рік тому

      I never created an edited version of these, but you can find the live streams on the archive channel.
      React Client First Try - ua-cam.com/video/blqEd9WIcYI/v-deo.html
      React Client Re-Do - ua-cam.com/video/M7K0be9gBeY/v-deo.html
      Vue Client Part 1 - ua-cam.com/video/JwS9nxwC1Vw/v-deo.html
      Vue Client Part 2 - ua-cam.com/video/JOoWbxvcSAg/v-deo.html

  • @mahmoudalaskalany
    @mahmoudalaskalany 2 роки тому

    His explanation is awesome ✨

  • @instinct_gallant8694
    @instinct_gallant8694 2 роки тому

    up to now. Your soft is great too!

  • @The-Average-Gamer
    @The-Average-Gamer 2 роки тому

    Hey where is the config loader vid?

  • @TheArmenianSolider65
    @TheArmenianSolider65 2 роки тому +2

    How does Zod compare to Mongoose?

    • @CodingGarden
      @CodingGarden  2 роки тому +9

      zod is just a schema validation and type inference library. mongoose is a wrapper on top of the mongodb library that adds ORM like features. This app was simple enough that we didn't need the extra features mongoose provides.

  • @saifashraf2135
    @saifashraf2135 Рік тому

    Thank you so much man

  • @LawZist
    @LawZist 2 роки тому

    event driven project with pubsub and message broker would be awesome!

  • @SouUmPanda
    @SouUmPanda Рік тому

    learned content. Thnx

  • @eneskrl3393
    @eneskrl3393 2 роки тому

    awesome content, thanks

  • @walkingin6375
    @walkingin6375 Рік тому

    Why is it such a headache and takes so much work to just make a rest api in TS?
    Go + Gin is so much cleaner, and easier to write it out. :/

  • @1nf0rmm3pls9
    @1nf0rmm3pls9 2 роки тому

    I learned a fucking lot. Respect for that awesome lesson!

  • @ozgenduru9165
    @ozgenduru9165 2 роки тому

    tNice tutorials actually was, and I'm just starting myself, I have no idea what I'm doing but I have a ton of ideas in my head. Ti to figure tNice tutorials out

  • @xtraszone
    @xtraszone Рік тому

    Instead of zod, you should use super-easy-validator

  • @lakessbm
    @lakessbm 2 роки тому

    nice video...wish you didnt skip over the mongodb setup though

    • @CodingGarden
      @CodingGarden  2 роки тому

      You can read how to install mongodb here: www.mongodb.com/docs/manual/administration/install-community/

    • @lakessbm
      @lakessbm 2 роки тому

      i ran the brew commands and have mongod process running on my comp but i never setup any connect uri on mongodb side, so how is the express side going to connect to it? im about 30 mins trhough the tutorial and when i run test after the db.ts setup, i get "MongoNotConnectedError: Client must be connected before running operations". appreciate any help

    • @lakessbm
      @lakessbm 2 роки тому

      i see, i think my mongodb is not setup properly, having issues with creating /data/db. will get back to you

    • @lakessbm
      @lakessbm 2 роки тому

      this step doesnt seem to be covered in mongodb documentation.

    • @gabrielfarias6273
      @gabrielfarias6273 2 роки тому +1

      use MongoDB Atlas

  • @sourav_-_7038
    @sourav_-_7038 2 роки тому

    bro, do some distributed nodejs application, like distributed chat app and other things.

  • @tcgvsocg1458
    @tcgvsocg1458 2 роки тому

    do i hit the like bouton on this video? not yet ok done

  • @philthy-phil
    @philthy-phil 2 роки тому +1

  • @saminyasar004
    @saminyasar004 2 роки тому

    I think it would be better to use a little background music. Personal preference 🥰

  • @barcalover016
    @barcalover016 Рік тому

    god dmnit why you all programmers love to name evrything "todo"

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

      they do so because they want you to define your todos in that todo

  • @ryan_roga
    @ryan_roga 2 роки тому

    `npx create-express-api --typescript --directory` no longer works.
    "error: unknown option `typescript'
    usage: git clone [] [--] []
    -v, --verbose be more verbose
    -q, --quiet be more quiet
    --progress force progress reporting
    -n, --no-checkout don't create a checkout
    --bare create a bare repository
    --mirror create a mirror repository (implies bare)
    -l, --local to clone from a local repository
    --no-hardlinks don't use local hardlinks, always copy
    -s, --shared setup as shared repository
    --recurse-submodules[=]
    initialize submodules in the clone
    --recursive[=]
    alias of --recurse-submodules
    -j, --jobs number of submodules cloned in parallel
    --template
    directory from which templates will be used
    --reference reference repository
    --reference-if-able
    reference repository
    --dissociate use --reference only while cloning
    -o, --origin use instead of 'origin' to track upstream
    -b, --branch
    checkout instead of the remote's HEAD
    -u, --upload-pack
    path to git-upload-pack on the remote
    --depth create a shallow clone of that depth
    --shallow-since
    create a shallow clone since a specific time
    --shallow-exclude
    deepen history of shallow clone, excluding rev
    --single-branch clone only one branch, HEAD or --branch
    --no-tags don't clone any tags, and make later fetches not to follow them
    --shallow-submodules any cloned submodules will be shallow
    --separate-git-dir
    separate git dir from working tree
    -c, --config
    set config inside the new repository
    --server-option
    option to transmit
    -4, --ipv4 use IPv4 addresses only
    -6, --ipv6 use IPv6 addresses only
    --filter object filtering
    --remote-submodules any cloned submodules will use their remote-tracking branch
    --sparse initialize sparse-checkout file to include only files at root
    rm: unknown option -- typescript/.git"