MVC Model-View-Controller Example | CRUD REST API | Node.js & Express tutorials for Beginners

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


(00:00) Intro
(00:05) Welcome
(00:14) Intro and Setup
(00:51) Model and View directories
(01:46) Creating an employees controller
(07:10) Project clean-up
(10:25) CRUD API Challenge Solutions
(17:22) Testing the CRUD API
(19:52) Source Code discussion

📚 References:

✅ Follow Me:

Was this tutorial about how to apply the MVC (Model-View-Controller) design pattern with Express JS helpful? If so, please share. Let me know your thoughts in the comments.

#mvc #express #node
Рекомендации по теме
Комментарии
Автор

Thank you so much Dave :). This course has really made my transition into backend easy and interesting 🤝

abdourahman
Автор

you're an amazing teacher!! thanks for sharing this tutorial and keep doing them!!!

AgustinAstronomy
Автор

Я лайкаю все новые видео сразу же. Ибо результат всегда на высоте гарантированно! А потом уже смотрю, когда есть время. Большое спасибо!

cradleofkaschenko
Автор

interested way to explain everything was amazing to understand ...well explantion thank u

anjazat
Автор

Hi, I'm wondering whether I should be using immutability for my functions or not(I've done mine without and tested it out and it seems to be working fine), additionally using immutability consumes more data storage from what I know, and for a larger amount of data that could come into play, afterall im updating the existing database always and not creating a new one so it shouldnt be required but maybe its better viewed or actually is better in some other way or maybe I'm supposed to use it interchangebly depending on each case? Thank you for your great videos

MietekPomywacz
Автор

Excellent reference as always!! Thank You Dave….

gordonmullen
Автор

Спасибо!!! Отличный канал, прекрасный педагог! Успехов!

sbvezdp
Автор

Great tutorial! I learned something new. I really appreciate the explanations

patrickkurth
Автор

6:49 how we handle put and delete to this path without dinamic paramethar like :id?

thebocksters
Автор

Hi Dave, cool node+express series, as well as a channel in general, I love the way you explain details. Can you advise if there is some balance between the amount of code in Routers and Controllers? I'll explain a bit. I had 90% of all my code directly in the Routers, inside the "(req, res) => {}" functions, I thought the code would work faster, neglecting the convenience of writing, refactoring, etc. I had literally thousands of lines of code in my routers.
Recently I've redone everything and transferred all my code to the respective controllers. However, I believe, there should be some balance between the two. A lot of similar imports in my controllers make me think about some sort of inefficiency. I came from very ancient languages like Assembler, Basic, Pascal, etc. :)) where repeating was treated as something very bad and inefficient, even an extra semicolon was bad)) not to mention entire models or other controllers. The logic behind was really simple - the compiler will bring all the imports into 1 file anyway. I realize that the browser does not compile JS))) however, the entire chain ends up on hardware anyway... Thus I'm wondering about your approach, experience, or even thoughts in this regard, thank you in advance.

biggand
Автор

Great tutorial on getting started with Express using the MVC Pattern. Thanks, Dave

{2022-06-10}

Pareshbpatel
Автор

Beside organizing the code, what I really like about MVC design pattern (or alike) is that we can separate the code facing the outside world (controller) from other codes dealing directly with the data (model),

regarding createEmployee handler, getting a new id by incrementing the last employee id will work fine as long as our data is sorted by id (which is the case here), but if we for some reasons have the data unsorted or sorted by something other than id then I think it cold be better to find the max id + 1
anyways, using a real database engine IDs can be auto generated,

for the unsortedArray.sort function, although it's much clearer this way but it can be made shorter by returning a.id - b.id (I think you mentioned this in a previous video but don't remember where)

Thanks Dave for keeping us thinking

ahmad-murery
Автор

Thank you very much.

In this lesson (after copy-pasting your source code) -
Thunder Client doesn't respond to requests
While the server runs on port 3500.

It did work during the Router video (where I manually wrote anything you did).

shineLouisShine
Автор

Can we just use sort((a, b) => a.id - b.id) instead of sort((a, b) => a.id > b.id ? 1: a.id < b.id ? -1 : 0) in updateEmployee when sorting the array?

jinlu
Автор

Hi, Dave! First of all - thank you for all the great tutorials!

I have a question about response data transformation. Should it be done in the controller layer or should there be an additional "service" layer between the controller and the model?

Thanks!

TheRoseWoodBody
Автор

Hi Dav, Grate tutorial, Thank you for that. I have a question we have different libraries for API development expressJS, NestJS many more can you suggest me which is best for a realtime steaming application which should read data from a data bricks server continuously

deepikaarava
Автор

I took a small brake because the Course became very advanced. It is hard to progress building the project at the same time when it is at the beginning level. Now I am practicing very basic "Express JS Crash Course" by Traversy Media youtube channel, but I am coming back soon, and surely I will finish it.

piotrekjazz
Автор

I have a question on part 14:20. When you run employee.firstname = req.body.firstname, wouldnt it mutate the existing employee object in the existing array? In that case isnt it unneccesary to remove the object from array and add it again?

skyhs
Автор

For sorting the array in ascending order with respect to employees' id in the updateEmployee() function, it would be better the usage below. Just as a recommendation.

data.setEmployees(unsortedArray.sort((a, b) => a.id - b.id))

ahmetkaya
Автор

Could you please upload a video that explains authentication; like how to consume a signup and a login endpoint with Javascript or react? thanks

thdisciples