Dependency Injection in JavaScript

  Рет қаралды 42,935

Sam Meech-Ward

Sam Meech-Ward

Күн бұрын

Пікірлер: 52
@leetcodeking4859
@leetcodeking4859 2 жыл бұрын
Thank you Sam. Please keep making videos. You are 1000% easier to understand than my teachers. You are a life send. Thank you 100 times.
@AmberCheaaa
@AmberCheaaa 3 жыл бұрын
This was very clear. I was struggling to understand the concept but with this I get it completely now! Thanks
@NeilTruick
@NeilTruick 2 жыл бұрын
My primary development language is C#, so I was very interested in learning how to mock for testing in TypeScript. I've got a few years of JavaScript under my belt, but never got into DI there. I came to this video from your "Mocking a Database in Jest" video. If the explanation is clear there as it was here, you have my deepest gratitude and appreciation, as well as a new subscriber.
@vesh95
@vesh95 2 жыл бұрын
Thanks. Спасибо! Почему-то я не догадывался строить приложение таким образом. Возможно под влиянием laravel и других фреймворков я упускал понимание работы механизмов более низкого уровня и пытался реализовать создание корневого объекта приложения во входном файле. Очень рад, что посмотрел данное видео)
@sheikhahnafhasan2830
@sheikhahnafhasan2830 3 жыл бұрын
You got a sub bro. You're awesome. Your channel will get 1M hit too soon. I hope. You've very quality content. Please, make a playlist on React testing too
@rickvian
@rickvian 3 жыл бұрын
great explanation just a small feedback that your music is louder than your voice and thats kind of annoying
@gb469x
@gb469x 2 жыл бұрын
Code Fastforwards : 3:25 - database.js 6:55 - wrapping database calls in app.js inside a function 9:00 - passing a custom database object to the app
@eduardocarvalho4232
@eduardocarvalho4232 3 жыл бұрын
Very nice explanation. Thanks Sam. Greetings from Portugal 🤗
@alvaro1121
@alvaro1121 9 ай бұрын
Thank you and kudos! Very easy to understand, and you give a lot of great examples that can fit right into real life projects.
@leovvvvv
@leovvvvv 3 жыл бұрын
Thanks for the great tutorial, Sam! One feedback though; the music is a bit louder than your voice, so I have to decrease the volume whenever you fast forward
@learningforever2531
@learningforever2531 Жыл бұрын
Hi, In case we separate the route and controller (move the route to route file, controller to controller file), how we inject database
@ilhamkaddouri7038
@ilhamkaddouri7038 3 жыл бұрын
This is great looking forward advanced topics about testing! Thank you
@sajjad.ilcsms
@sajjad.ilcsms Ай бұрын
Great example, finally i get it
@maxlupey2787
@maxlupey2787 2 жыл бұрын
Awsome explanation
@aliasanov8790
@aliasanov8790 3 жыл бұрын
Great explanation! Keep it going please :-)
@marioserano4098
@marioserano4098 2 жыл бұрын
it was a very clear explanation, very cool!
@Tozaroo
@Tozaroo 3 жыл бұрын
this was awesome, thank you!
@alfonsoramirezelorriaga1153
@alfonsoramirezelorriaga1153 11 ай бұрын
Great way to explain the pattern. Thank you! Just one question, is having all your queries to the db in a single file a good practice or a conventional practice? I just have not seen that before.
@martinvanlaethem543
@martinvanlaethem543 3 жыл бұрын
good stuff
@clasesutnfrc8699
@clasesutnfrc8699 2 жыл бұрын
05:32 Use Dependency Injection
@saulramirez727
@saulramirez727 2 жыл бұрын
Great video
@nimser
@nimser Жыл бұрын
Super nice, thanks. How would you do if the database isn't directly used in the app, but in a router or in a controller called from that router ? I'm having a hard time trying to apply these principles to an app wired this way.
@sammygopeh7578
@sammygopeh7578 2 жыл бұрын
Another amazing....THANK YOOOUU SAM!!
@SamMeechWard
@SamMeechWard 2 жыл бұрын
Glad you enjoyed it!
@jimmyfitzsimmons7170
@jimmyfitzsimmons7170 3 жыл бұрын
Love your work dude but the songs u play during your fastforward makes me want to throw away my headphones everytime ^^
@SamMeechWard
@SamMeechWard 3 жыл бұрын
🤣 I’m open to music suggestions
@lexNwimue
@lexNwimue Жыл бұрын
Great explanation. Succint! Just need to reduce the volume of the music though. It'll be better if it played somewhat subtly in the background. 👍
@joshj.7764
@joshj.7764 Жыл бұрын
Thanks for making this video! I've always liked test-driven development. But I do have a question - what's the syntax for injecting the database dependency if your routes are in another file? for example app.ts has: app.user('/api/user', userRoute); //where your post route is in userRoute.js
@Sam-nm1ix
@Sam-nm1ix 3 жыл бұрын
Did you hire a professional to select your intro songs? They're always so good.
@SamMeechWard
@SamMeechWard 3 жыл бұрын
I have an unpaid intern
@Sam-nm1ix
@Sam-nm1ix 3 жыл бұрын
@@SamMeechWard you should start paying her
@AndreaCiani
@AndreaCiani 3 жыл бұрын
Great tutorial!!! Thanks!!
@tukuyoma
@tukuyoma 3 жыл бұрын
please how do I achieve dependency injection when I have different route files and import all the routes into the index app
@SamMeechWard
@SamMeechWard 3 жыл бұрын
I hope this makes sense, i'm just going to write the code in the youtube comment // someRoute.js const express = require('express') export function(database) { const route = express.route("/something") route.get("/", (req, res) => {}) return route } // app.js const makeSomeRoute = require('./someRoute.js') .... makeSomeRoute(database)
@herrklaus
@herrklaus 3 жыл бұрын
@@SamMeechWard wouldn't this be express.Router?
@thatsalot3577
@thatsalot3577 Жыл бұрын
But what if you have a lot of routes and they're stored in different files, do I have to drill down the database object to every single controller and middleware ?
@gosnooky
@gosnooky Жыл бұрын
Technically, ,if a username already exists you would use the 409 Conflict status. I know it's not germane to the tutorial, it's just a random nugget of information for anyone who builds HTTP servers. I always suggest using HTTP status semantics so consuming applications can derive the error from the calling context without having to parse the error message text, or introducing custom domain-specific error codes. Then for a specific request, the front-end say, will know that when a conflict is thrown, a user with the username already exists.
@snake1625b
@snake1625b 2 жыл бұрын
what if youre using controllers for each route, then you wouldnt be creaitng the app in each controller right?
@mertgenc9890
@mertgenc9890 3 жыл бұрын
hey thanks a lot for the amazing video. could you make a video about applying dependency injection to graphql server?
@SamMeechWard
@SamMeechWard 3 жыл бұрын
I love the suggestions. It might be a while until I do any videos with GraphQL though.
@indestructible-today
@indestructible-today 3 жыл бұрын
You talk, and I hear henry cavill's voice. great tutorial btw.
@armanabrahamyan9714
@armanabrahamyan9714 2 жыл бұрын
it is wonderful
@berkaybayrak7876
@berkaybayrak7876 2 жыл бұрын
I have a question, what if my requestHandlers are different file how can ı send database
@alexpiano
@alexpiano Жыл бұрын
NIce videos. If I may, each time you put a music I find the volume is a little too high and kinda distuptive for focusing. Anyway, I just silenced these parts. Keep up the good work.
@EvgenyT2011
@EvgenyT2011 2 жыл бұрын
Thanks!
@Richie43
@Richie43 2 жыл бұрын
You need to use Typescript and tsyringe
@valentoMundrov
@valentoMundrov 3 жыл бұрын
Greetings, thank you for the nice video (all of them), here is my question: If createApp imports a function, doesn't it executes it straight by importing it? Don't you instantiate two apps now? Isn't it better to assign your app-function into an Object and export the object, instead, so you can initiate the app from your server code?... or I'm just wrong :) ps. I understand the video is just basic, yet the question is for my own sake :)
@ehSamurai3483
@ehSamurai3483 2 ай бұрын
Isn't this the Strategy Pattern?
@davidkhierl696
@davidkhierl696 Жыл бұрын
music too loud
@AllanAlmeidaOficial
@AllanAlmeidaOficial Жыл бұрын
Good vídeo, but please don’t put that song so loud, it’s really annoying
@babykosh5415
@babykosh5415 2 жыл бұрын
This (TDD) is a niche market ... no one is paying attention too....keep at it
@bariswheel
@bariswheel 2 жыл бұрын
Great stuff but music not my cup of tea at all, please turn it down a bit, too distracting
Mocking a Database in Node with Jest
13:29
Sam Meech-Ward
Рет қаралды 70 М.
Dependency Injection basics- Fun Fun Function
22:26
Fun Fun Function
Рет қаралды 153 М.
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН
Правильный подход к детям
00:18
Beatrise
Рет қаралды 11 МЛН
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН
#10 Constructor and Setter Injection in Spring
15:47
Telusko
Рет қаралды 39 М.
Dependency Injection & Inversion of Control
11:00
Ryan Schachte
Рет қаралды 201 М.
JavaScript Promises Crash Course
24:03
Kevin Powell
Рет қаралды 39 М.
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 905 М.
JavaScript Pro Tips - Code This, NOT That
12:37
Fireship
Рет қаралды 2,5 МЛН
Dependency Inversion Principle Explained - SOLID Design Principles
13:00
Web Dev Simplified
Рет қаралды 165 М.
#6  Dependency Injection using Spring Boot
13:34
Telusko
Рет қаралды 81 М.
TypeScript Dependency Injection using tsyringe
7:12
Kris Foster
Рет қаралды 34 М.
Node.js is a serious thing now… (2023)
8:18
Code With Ryan
Рет қаралды 663 М.
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН