MENU

Fun & Interesting

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

Coding Garden 53,638 2 years ago
Video Not Working? Fix It Now

This was edited from a live stream on twitch. Follow on twitch to watch live: https://twitch.tv/codinggarden View the code here: https://github.com/CodingGarden/intro-to-typescript/tree/examples/examples/express-api πŸ“© Sign up for my mailing list: https://list.coding.garden/ πŸ’– Donate: https://coding.garden/donate 😍 Pledge: https://coding.garden/pledge πŸ’¬ Discord: https://coding.garden/discord πŸŽ‰ Stickers: https://coding.garden/stickers πŸ’» Gear List: https://coding.garden/gear πŸ”Ž Search for more Coding Garden videos here: https://coding.garden/videos πŸ—£ View the Coding Garden FAQ here: https://github.com/CodingGarden/faqs 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

Comment