Express JS with TypeScript - Setup, Examples, Testing

  Рет қаралды 12,651

Anson the Developer

Anson the Developer

Күн бұрын

DISCLAIMER
This is NOT a full in depth tutorial on Express JS. It is only designed to walk you through the setup process of installing TypeScript, getting it up and running with Express, and show you examples of type annotating arguments. I have also added other examples with Unit Testing & Integration testing with Jest and ts-jest.
I highly recommend you use this as a way to learn how to setup a TypeScript project for Express, and then slowly migrate over your code. Many of the concepts covered in my Express JS Full Course can easily be translated over once you get the idea of what to type annotate.
Link to Express JS 8 Hour Course: • Express JS Full Course
Code Repository: github.com/stuyy/express-type...
Support the Channel:
Become a Member: kzbin.info...
Become a Patreon: / stuyy
Buy me a Coffee: ko-fi.com/anson
Donate on Streamlabs: streamlabs.com/ansondevacadem...
Donate on PayPal: paypal.me/ansonfoong
Connect with me:
Twitter: / ansonthedev
Discord: / discord
GitHub: github.com/stuyy
Twitch: / stuy
0:00 - Project Setup
3:00 - Install Typescript
8:40 - tsconfig.json file
9:44 - Configuring TypeScript
13:00 - Compile TS Files
16:30 - Nodemon with Typescript
20:27 - Basic Type Annotations
35:08 - Type annotate Request Body
41:22 - Type annotate Query Parameters
43:41 - Type annotate Route Parameters
44:38 - Type annotate Response Body
51:06 - Extend Request Interface
54:50 - 3rd Party Libraries with TS
59:45 - Unit Tests with Jest and TS
1:08:25 - Integration Tests with Supertest
1:20:45 - Integration Tests

Пікірлер: 48
@ayushshende4290
@ayushshende4290 2 ай бұрын
Next tutorial can be a complete monorepo (like turborepo) with this stack, bonus add dockerization and deployment as well. Thanks for the amazing content.
@naddulidaniel2630
@naddulidaniel2630 2 ай бұрын
I have been waiting for this tutorial. Here we are. Thank you very much.
@kncsmooth8737
@kncsmooth8737 2 ай бұрын
Your clear explanations, detailed examples, and thorough coverage made it a breeze to follow along and understand. I truly appreciate the effort you put into creating such valuable content. Looking forward to more tutorials from you in the future! Keep up the fantastic work!
@ansonthedev
@ansonthedev 2 ай бұрын
Thanks a lot! I do try my best when making vids like these, so to hear stuff like this is very much appreciated. :)
@user-pz3wj3yk2x
@user-pz3wj3yk2x 10 күн бұрын
Super helpful, thank you!
@RatherBeCancelledThanHandled
@RatherBeCancelledThanHandled Ай бұрын
Explained clearly ; well done 👍
@rupeshthapa8891
@rupeshthapa8891 Ай бұрын
This is very informative, thank you very much for the tutorial❤
@sayeddileri3461
@sayeddileri3461 2 ай бұрын
Thank you so much Anson for this I am currently diving into testing and this is just perfect to help me get started. Thank you!!!
@ansonthedev
@ansonthedev 2 ай бұрын
Glad to hear that. You're welcome. :D
@johnattaiyinusa5766
@johnattaiyinusa5766 2 ай бұрын
Great job, Anson
@jens2504
@jens2504 2 ай бұрын
Awesome tutorial!
@prashlovessamosa
@prashlovessamosa 2 ай бұрын
Thanks Anson.
@Error404Codes
@Error404Codes 2 ай бұрын
i got my server down when i declare the index.d.ts for extend request interface , the controller file did not show erro and ts knows the property but server goes down Property 'CustomField' does nto type 'Request
@riyad-appscode
@riyad-appscode 2 ай бұрын
awesome tutorial. Thanks for the video
@ansonthedev
@ansonthedev 2 ай бұрын
You're welcome. Thanks! :D
@maximoignacio6959
@maximoignacio6959 Ай бұрын
Thank you very much! 1:14:55 import express from 'express'; let app: ReturnType; should work as well.
@malikkadyraliev4871
@malikkadyraliev4871 2 ай бұрын
U r best, hello from Kyrgyzstan, really appreciate ur videos 👍
@ansonthedev
@ansonthedev 2 ай бұрын
Thank you :)
@gunasekarant6498
@gunasekarant6498 Ай бұрын
Awesome one Thank you so much
@ansonthedev
@ansonthedev Ай бұрын
You are welcome!
@chamaraweerasinghe3909
@chamaraweerasinghe3909 Ай бұрын
greate content keep up the good work
@mohiwalla
@mohiwalla 2 ай бұрын
Good job 👍👏
@ansonthedev
@ansonthedev 2 ай бұрын
Thanks! :D
@jellyfish1772
@jellyfish1772 Ай бұрын
Thank you so much ..
@ansonthedev
@ansonthedev Ай бұрын
You’re welcome
@deathscythe3124
@deathscythe3124 21 күн бұрын
How come you didn’t get an error when you name your user.ts router a const route then call it in index.ts as import userRouter. Im confuse. Please explain it to me
@masadsummair
@masadsummair Ай бұрын
Thanks for rich content . I just want to ask how you learn these concept like nestjs and other along with best practices any sources?
@ansonthedev
@ansonthedev Ай бұрын
When you're a beginner, it's fine to refer to KZbin videos or courses on platforms like Udemy. When you become more advanced, you learn how to refer to documentation and build intuition with your experience.
@iUmerFarooq
@iUmerFarooq 2 ай бұрын
When are you going to upload an advance ExpressJs tutorial? Thanks for this awesome tutorial 💚
@ansonthedev
@ansonthedev 2 ай бұрын
It's in the works. Thank you!
@smartdriver2990
@smartdriver2990 2 ай бұрын
Wow, interesting 🎉
@RobertMcGovernTarasis
@RobertMcGovernTarasis 2 ай бұрын
Very clear, thank you. You’ve now got my toes wet with typescript. 1 question, how come when you ran npm run test:e2e it only ran 1 test for you, but for me it’s running both the e2e test, and the handler test?
@ansonthedev
@ansonthedev 2 ай бұрын
My guess would be you may have forgot to set the flag for the test:e2e script to run tests only in the src/e2e folder. By default it will run all .test.ts or .spec.ts test files.
@sdawdwadaufyuaiudi2148
@sdawdwadaufyuaiudi2148 29 күн бұрын
almost every coures I find on youtube use any, only you explain what going in generic 40:17 ,thank . Is there any cheatsheat TypeScript for express,I can only cheatsheat for reactjs,it kinda suck
@mahmoudnada2120
@mahmoudnada2120 2 ай бұрын
I hope you will make a live stream again with a program that is stronger than chat🌺
@igmtink
@igmtink 2 ай бұрын
can you make a tutorial how to setup both nextjs + expressjs with typescript sir? like nextjs for frontend and expressjs with typescript for backend just a simple to-do or any
@prerakhere
@prerakhere Ай бұрын
I don't understand when to use express-serve-static-core v/s express
@jayjaayjaaay94
@jayjaayjaaay94 8 сағат бұрын
1:05:46 how to differentiate one request to others?
@mythmaker6155
@mythmaker6155 Ай бұрын
I am sorry to ask you this. but I am new to Express with TypeScript. i worked with django. But for expanding my tech stack i am learning to express the best way. One thing i loved in django(Django-ninja) was automatic API documentation. is there any way to achieve similar functionality in Express? I did search API documentation with Express but all I find is manual documentation. If there is any way to automatically generate documentation with Joi or TS interface it would be really helpful. BTW love the video. it got me started TS with Express
@ansonthedev
@ansonthedev Ай бұрын
There is Swagger, not sure about it being automatic, but it does provide documenting your APIs for you.
@nithya4860
@nithya4860 2 ай бұрын
Wow!
@abhayshaw1875
@abhayshaw1875 2 ай бұрын
Hey can we have a video on an opionated one :adonis js??
@marcschiavone9549
@marcschiavone9549 2 ай бұрын
I believe it doesnt make much sense since here they explain the whole typescript + express setup and adonisjs is already typescript ready.
@Pransshhh
@Pransshhh 2 ай бұрын
Should include how to host these on vercel or something like that
@ansonthedev
@ansonthedev 2 ай бұрын
Not relevant to the tutorial.
@Pransshhh
@Pransshhh 2 ай бұрын
@@ansonthedev Please make a video on this
@devfabien
@devfabien Ай бұрын
This is an amazing tutorial. I would like to seek your recommendation; based on what you showed in tutorial most in the part of e2e test what is your point of view in using `App` type from supertest/types instead of assigning variable app to `Express` type. kzbin.info/www/bejne/eJaaiWmHf9qmgKM
@ansonthedev
@ansonthedev Ай бұрын
I used "Express" because that's the inferred type from the express() function call that is returned. Never knew there was an App type. But I never had any issues using the Express type.
How Did I Not Know This TypeScript Trick Earlier??!
9:11
Josh tried coding
Рет қаралды 201 М.
How To Use TypeScript With Express & Node
17:05
Colt Steele
Рет қаралды 62 М.
Black Magic 🪄 by Petkit Pura Max #cat #cats
00:38
Sonyakisa8 TT
Рет қаралды 19 МЛН
OMG 😨 Era o tênis dela 🤬
00:19
Polar em português
Рет қаралды 11 МЛН
NO NO NO YES! (50 MLN SUBSCRIBERS CHALLENGE!) #shorts
00:26
PANDA BOI
Рет қаралды 102 МЛН
Did you find it?! 🤔✨✍️ #funnyart
00:11
Artistomg
Рет қаралды 122 МЛН
Typescript API in NodeJS / Express in Depth [Part 1]
38:10
The Nerdy Canuck
Рет қаралды 2,6 М.
Learn TypeScript Generics In 13 Minutes
12:52
Web Dev Simplified
Рет қаралды 209 М.
Express Crash Course (2024 Revamp)
1:46:11
Traversy Media
Рет қаралды 37 М.
I Cannot Believe TypeScript Recommends You Do This!
7:45
Web Dev Simplified
Рет қаралды 158 М.
7 Awesome TypeScript Types You Should Know
8:57
Josh tried coding
Рет қаралды 75 М.
Полная настройка Node.js с TypeScript в 2023
17:36
Владилен Минин
Рет қаралды 34 М.
🇮🇩Let’s go! Bali in Indonesia! 5GX Bali
0:44
ISSEI / いっせい
Рет қаралды 39 МЛН
Nika ate all my fish🥲 #cat #cats
0:19
Princess Nika cat
Рет қаралды 126 МЛН