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

  Рет қаралды 51,584

Coding Garden

Coding Garden

Күн бұрын

Пікірлер: 67
@atraps7882
@atraps7882 2 жыл бұрын
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
@AngelHdzMultimedia
@AngelHdzMultimedia 2 жыл бұрын
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.
@kraldragon1324
@kraldragon1324 Жыл бұрын
this is what i am searching. Thanks for sharing
@mahmoudalaskalany
@mahmoudalaskalany 2 жыл бұрын
His explanation is awesome ✨
@1nf0rmm3pls9
@1nf0rmm3pls9 Жыл бұрын
I learned a fucking lot. Respect for that awesome lesson!
@LawZist
@LawZist 2 жыл бұрын
event driven project with pubsub and message broker would be awesome!
@eneskrl3393
@eneskrl3393 Жыл бұрын
awesome content, thanks
@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?
@gabrielfarias6273
@gabrielfarias6273 2 жыл бұрын
totally makes sense, totally not gonna happen
@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 - kzbin.info/www/bejne/mJ3UdpdvjK6Wj6s React Client Re-Do - kzbin.info/www/bejne/g2iuYZWbbsx1m7s Vue Client Part 1 - kzbin.info/www/bejne/gKi2aqGurKhkjNk Vue Client Part 2 - kzbin.info/www/bejne/gIDSiJWuq8iGd8k
@TheArmenianSolider65
@TheArmenianSolider65 2 жыл бұрын
How does Zod compare to Mongoose?
@CodingGarden
@CodingGarden 2 жыл бұрын
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.
@walkingin6375
@walkingin6375 10 ай бұрын
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. :/
@philthy-phil
@philthy-phil Жыл бұрын
@tcgvsocg1458
@tcgvsocg1458 2 жыл бұрын
do i hit the like bouton on this video? not yet ok done
@prerakhere
@prerakhere Ай бұрын
I learn so much extra stuff everytime i see your livestream. Thanks.
@AJax2012
@AJax2012 2 жыл бұрын
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...
@leonardozerino9628
@leonardozerino9628 Жыл бұрын
i'm also looking for it
@MistaT44
@MistaT44 2 жыл бұрын
Great stuff as always, thanks CJ!
@daninmanchester
@daninmanchester Жыл бұрын
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.
@andianwar5784
@andianwar5784 Жыл бұрын
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!
@vittorio9449
@vittorio9449 Жыл бұрын
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 KZbin? Thanks so much
@dannorcott773
@dannorcott773 Жыл бұрын
Great bloke, great video, great all round! Thanks CJ, helped me a lot.
@tusharjaiswal3133
@tusharjaiswal3133 8 ай бұрын
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.
@wintoniw703
@wintoniw703 2 жыл бұрын
You're so advanced, CJ! Also, your effort in sharing in-demand knowledge is immense! Bless your heart!
@zlatkoiliev8927
@zlatkoiliev8927 2 жыл бұрын
So so happy I have subscribed to your channel!!! I have learned really a TON thanks to your vids!
@Luke-Barrett
@Luke-Barrett Ай бұрын
With the latest version of nodemon you don't need to install ts-node separately.
@xtraszone
@xtraszone 10 ай бұрын
Instead of zod, you should use super-easy-validator
@bruhgoaway4876
@bruhgoaway4876 2 жыл бұрын
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 жыл бұрын
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 👍
@TheUltimateGeminiHasSurvived
@TheUltimateGeminiHasSurvived Жыл бұрын
Keep up the great work! I used to be active in your Discord. I love how respectful you are! Awesome work, Cody!!
@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! 💖💚💛
@vickyvirat5166
@vickyvirat5166 11 ай бұрын
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🙏
@barcalover016
@barcalover016 10 ай бұрын
god dmnit why you all programmers love to name evrything "todo"
@prerakhere
@prerakhere Ай бұрын
they do so because they want you to define your todos in that todo
@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!
@cinegolpo-movieexplainedin8192
@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
@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
@instinct_gallant8694
@instinct_gallant8694 2 жыл бұрын
up to now. Your soft is great too!
@saminyasar004
@saminyasar004 2 жыл бұрын
Great video. Thank you very much, CJ. Take love💚
@The-Average-Gamer
@The-Average-Gamer 2 жыл бұрын
Hey where is the config loader vid?
@vivuuc4209
@vivuuc4209 Жыл бұрын
what is name of theme extension you use?
@SouUmPanda
@SouUmPanda Жыл бұрын
learned content. Thnx
@saifashraf2135
@saifashraf2135 Жыл бұрын
Thank you so much man
@Thinna
@Thinna Жыл бұрын
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 8 ай бұрын
Have you found any better solution?
@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
@wintoniw703
@wintoniw703 2 жыл бұрын
Right on, right on!
@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 жыл бұрын
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.
@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 жыл бұрын
use MongoDB Atlas
@sourav_-_7038
@sourav_-_7038 2 жыл бұрын
bro, do some distributed nodejs application, like distributed chat app and other things.
@saminyasar004
@saminyasar004 2 жыл бұрын
I think it would be better to use a little background music. Personal preference 🥰
@ryan_roga
@ryan_roga Жыл бұрын
`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"
Being Competent With Coding Is More Fun
11:13
TheVimeagen
Рет қаралды 81 М.
How To Use TypeScript With Express & Node
17:05
Colt Steele
Рет қаралды 71 М.
Minecraft Creeper Family is back! #minecraft #funny #memes
00:26
Electric Flying Bird with Hanging Wire Automatic for Ceiling Parrot
00:15
8 TypeScript Tips To Expand Your Mind (and improve your code)
10:54
How Did I Not Know This TypeScript Trick Earlier??!
9:11
Josh tried coding
Рет қаралды 212 М.
Typescript API in NodeJS / Express in Depth [Part 1]
38:10
The Nerdy Canuck
Рет қаралды 9 М.
I tried 8 different Postgres ORMs
9:46
Beyond Fireship
Рет қаралды 413 М.
Testing Node Server with Jest and Supertest
11:45
Sam Meech-Ward
Рет қаралды 118 М.
"The Life & Death of htmx" by Alexander Petros at Big Sky Dev Con 2024
23:01
Montana Programmers
Рет қаралды 60 М.
Node.js is a serious thing now… (2023)
8:18
Code With Ryan
Рет қаралды 650 М.
Zod + Generics is HEAVEN
4:41
Matt Pocock
Рет қаралды 58 М.
Minecraft Creeper Family is back! #minecraft #funny #memes
00:26