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

preview_player
Показать описание


00:00:00 Intro
00:00:09 Hello Friends
00:01:00 Project Template
00:01:40 Clone Template
00:02:21 Template Overview
00:05:00 Typescript with Express
00:07:23 How to find Typescript libraries
00:09:21 Install zod and mongodb
00:09:43 Folder Structure
00:11:36 Create a schema with zod
00:14:39 Create todos router
00:18:59 zod default values
00:19:20 Restructure tests
00:21:31 Our first test
00:25:35 mongodb setup
00:29:23 collection / model setup
00:31:00 findAll handler
00:33:22 test beforeAll collection drop
00:34:47 close database connection after tests
00:36:23 jest and supertest explained
00:38:01 refactor request handlers
00:39:57 Service / Controller / DAL explained / best practices
00:43:25 Express Error Handling
00:46:18 createOne handler
00:49:55 createOne tests
00:58:30 tests are nice
00:59:01 request validation middleware refactor
01:07:40 findOne handler
01:13:09 findOne tests
01:16:00 zod ObjectId validation
01:20:43 updateOne handler setup
01:22:57 updateOne tests
01:27:23 updateOne handler implementation
01:29:02 deleteOne handler setup
01:30:28 deleteOne tests
01:32:29 deleteOne handler implementation
01:36:13 we did it
01:36:44 findAll correction
01:37:49 Thank You!
01:38:40 catJAM
Рекомендации по теме
Комментарии
Автор

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.

AngelHdzMultimedia
Автор

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

prerakhere
Автор

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🙏

vickyvirat
Автор

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

wintoniw
Автор

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

sunman
Автор

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

atraps
Автор

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

TheUltimateGeminiHasSurvived
Автор

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

dannorcott
Автор

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

_rushikesh_ganesh
Автор

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!

koti
Автор

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

zlatkoiliev
Автор

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!

andianwar
Автор

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

alexliebhaber
Автор

this is what i am searching. Thanks for sharing

kraldragon
Автор

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! 💖💚💛

tabliqatchi
Автор

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...

AJax
Автор

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

saminyasar
Автор

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.

daninmanchester
Автор

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 YouTube? Thanks so much

vittorio
Автор

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

Luke-Barrett