How to implement Clean Architecture in Node.js (and why it's important)

Поделиться
HTML-код
  • Опубликовано: 7 сен 2024
  • As software systems grow, they can start to become unmanageable, especially when working with teams of multiple engineers on a system planned to live for years. Following software architecture designs can help reduce this complexity by allowing you to easily swap out third party libraries and protector your business logic from being tightly coupled to these third party dependencies. You may argue tat clean architecture is overly complex and smells like over engineering, but you will more than likely need some form of software architecture standard when dealing with large code bases.
    ------------
    🔔 Newsletter eepurl.com/hnderP
    💬 Discord / discord
    📁. GitHub github.com/cod...

Комментарии • 165

  • @gregtaylor9806
    @gregtaylor9806 2 года назад +122

    I like this video because it’s about a specific design concept and not embedded in a massive beginner tutorial. There is not enough mid-level programming info like this. Thanks for making this and Keep it up!

    • @waelgh4307
      @waelgh4307 Год назад +8

      Right, it's hard to find quality content for mid or advanced concepts.

  • @TheAkiller101
    @TheAkiller101 Год назад +27

    This is a better tutorial on dependency injection and inversion of control than hour long lectures and videos I had to listen to on the same subject.

  • @brandonlange2260
    @brandonlange2260 2 года назад +52

    Clean architecture, hexagonal and Domain Driven Design are really abstract concepts. They all encapsulate some really great ideas but I also strongly believe that it's something that you shouldn't get too caught up in. Find a level of abstraction that works for you and roll with it. I went on a whole craze a couple years back designing systems with all of these concepts and even though I did build some really cool stuff, it was extremely overkill for what was actually required. Great video though as always! It would actually be really great to pick your brain sometime about some stuff! Can't wait for the next video!

    • @WebDevCody
      @WebDevCody  2 года назад +3

      You’d be surprised how empty my brain is ;). But if you have a particular topics you want me to talk about let me know

    • @exe2543
      @exe2543 11 месяцев назад +2

      Exactly!! The point of designing software is not to use the fanciest or most complex design, it's to get the job done and have a testable, maintainable, and resilient system.

  • @josephajibodu2377
    @josephajibodu2377 2 года назад +7

    I’ve spent a lot of time trying to understand this architecture. I’m always lost when I get to the inversion of control, thanks to your video, it has reinforced my understanding of this architecture.

  • @krskvBeatsRadio
    @krskvBeatsRadio 2 года назад +73

    Would be really interesting to see how you structure folders with this approach at your job!

    • @MattBidewell
      @MattBidewell 2 года назад +9

      I would separate the routing functions into a controller folder, the buisness logic into a services folder with say "UserService", "Email service" and then database or whatever classes into a "DAO" folder (data access object)

    • @tonienguix6503
      @tonienguix6503 Год назад

      also you would need a validation folder and provably helpers. good video here: ruclips.net/video/oNlMrpnUSFE/видео.html&ab_channel=PedroTech

    • @naughtiousmaximus7853
      @naughtiousmaximus7853 7 месяцев назад

      ​@@MattBidewell this sounds like NestJS?

  • @Izzat-bj1le
    @Izzat-bj1le 10 дней назад

    Finally a tutorial that actually implements clean architecture instead of talking about it. Thank you

  • @jordiyaputra8359
    @jordiyaputra8359 Год назад +1

    For many years, maybe +4 years I have been working with these kinds of code architecture and patterns but I absolutely have NOOO idea what I was doing. Now you are giving me an enlightment! I know you deserve more than this, but please accept my humble subscription to your channel 🙏

    • @WebDevCody
      @WebDevCody  Год назад +1

      thanks for the sub! I'm glad you found my content useful

  • @mibreit-photo
    @mibreit-photo 10 месяцев назад +3

    Nice video!
    General observation about clean architecture: I'm all for abstraction, but one has to know when to stop ;-) At some point - same as with clean code - instead of making your project more maintainable, you're creating spiderweb of dependencies (even if it's mostly just abstractions / interfaces). Then, understanding and debugging code can mean jumping through a myriad of files. It also depends largely on the size of the project. You need to understand when you should apply those concepts and when it is overkill. Always remember - YAGNI

  • @renepatznick2526
    @renepatznick2526 3 месяца назад

    I spent several hours struggling with the high-level description of the clean architecture diagram in the Clean Architecture book. Your explanation in the video was fantastic - it really clarified things for me. Now it all makes sense!

  • @matthew1106
    @matthew1106 Год назад +2

    Great job going over the important aspect of the concept instead of living in theoryland. Definitely much harder to demo this without using typescript.

  • @rohit3430
    @rohit3430 Год назад +1

    tomorrow is mine interview and i found this really helpful to explain how i have been doing previously and how this architecture could be helpful to improve further!
    thanks for the video!

  • @pguti778
    @pguti778 2 года назад +1

    Woooowwww, so clear and real !!! Complete agree that all these architecture things are too-too abstract. I think that architects (and most of the times the sellers) try to think this is magic, like it happened with Agile, or OOP. Thank you man !!!

  • @F4ILCON
    @F4ILCON 2 года назад +1

    This is the far most understanding videos for people that are starting to understand the Clean Architecture concept, my sugestion would be show how folders are set-up, thanks for the video

  • @mattiadevivo9775
    @mattiadevivo9775 Год назад +1

    Really well explained, they should teach this concept in each CS high school and university

  • @chrisbirkenmaier2277
    @chrisbirkenmaier2277 10 месяцев назад

    Would love to see a course about this topic. 3 hour video on how to create a clean application with node, nextjs, maybe some database, everything hooked up with docker compose, testing included. Would pay serious $$$ for something in that direction.

  • @aaronmotacek9343
    @aaronmotacek9343 Год назад +2

    I think this was great. I’m a sucker for code organization practices, but I haven’t looked into backend best practices until now. The examples you gave clearly illustrate the benefit and I think you have just the right amount of detail for anyone that is searching for this topic. Excited to look around your channel more. #subscribed

    • @hojdog
      @hojdog Год назад +2

      I don't think there's real difference between front and back end code architecture. You can apply these concepts to any codebase

  • @danielmaldonado5954
    @danielmaldonado5954 Год назад

    Awesome video ! Very clear. It's true most speakers talks hours and hours of abstract concepts. I like how you managed it to show a real world example in 20 minutes. Thank you !

  • @joseavilasg
    @joseavilasg 6 месяцев назад +1

    Thank you so much for this video. It was very helpful. Well explained.

  • @gosnooky
    @gosnooky 11 месяцев назад +2

    Raw-dogging JS like this is hard, even with TS. Our team started using NestJS which is based on dependency injection and this philosophy. It's slightly opinionated, but takes all the guesswork out of architecture, so any newcomers to the projects intrinsically have a working knowledge of the application without looking at a single line of code.

    • @WebDevCody
      @WebDevCody  11 месяцев назад

      I haven't tried nest.js yet, but it looks like a solid way to write a rest api from their docs

  • @travelwithahmedmurtaza
    @travelwithahmedmurtaza Год назад

    Very well explained. Instead of discussing abstract concepts you have covered a use case which becomes very easy to grasp the concept and much quickly. Thanks alot

  • @FeyroozeCode
    @FeyroozeCode 6 месяцев назад

    Good video, with nestJs all is inside the box (Clean architecture,Separation of concerns, Dependency Injectection etc..)

  • @AssassinNinja98
    @AssassinNinja98 4 месяца назад

    Thank you so much. I really like that you show the practical side of clean architecture

  • @sobhanm9576
    @sobhanm9576 2 года назад +1

    Fascinating content, most clean architecture are either simple examples or written in another language thanks for clear explanation, hope to see more content about ddd and clean architecture written in typescript 🙌🏻🙏

  • @rorythomas7851
    @rorythomas7851 2 года назад +1

    My friend, your content is amazing and such a big help. please dont ever stop

  • @NaveenThally
    @NaveenThally 2 года назад +4

    It's a nice explanation, if you could share the boiler plate code for clean architecture would be helpful. A series on clean architecture with es6 would also be helpful, Dependency injection as a topic is worth to cover.

  • @wichaisawangpongkasame9237
    @wichaisawangpongkasame9237 2 года назад

    You really nailed it! I've never understood the hexagonal architecture this much clearer. You do deserve more subscriber. Many thanks!

  • @caskispace
    @caskispace Год назад

    Thank you for the vid! Clear, straight to the point and from a perspective that is easier to grasp.

  • @captainnoyaux
    @captainnoyaux 7 месяцев назад

    I really like this topic ! Backend and frontend (I've not yet to find a video on clean architecture with redux thought is someone has one I'd love to take a peek at how people might use it)

  • @shahzaibshahzaibkhan6480
    @shahzaibshahzaibkhan6480 8 месяцев назад

    Very usefull, plus the actual example made everything a lot clearer than if it were just theory. ❤

  • @michaelpesin946
    @michaelpesin946 8 месяцев назад

    Great video!
    This a great example to send to junior developers

  • @logisticedits7429
    @logisticedits7429 Год назад +1

    Please make a full series of nodejs. But not basics but advance like how big scaling project code works, how uber uses nodejs

  • @sahaneakanayaka3394
    @sahaneakanayaka3394 7 месяцев назад +1

    Really enjoyed it. Great content. Thank You! 🙏❤

  • @adventurer2395
    @adventurer2395 7 месяцев назад

    Awesome! So you're basically organizing the system into framework agnostic controllers, a service layers for business logic, and a repositories to abstract db operations-everything with dependency injection and inversion. Question I have is:
    Do you like doing this at a granular level per use case. For example, create 3 three layers for each user use case, like createUser, updateUser, etc. Or do you prefer to encapsulate related functionality like having a controller, service, and repository/persistence that encapsulate all user-related operations?

  • @gbroton
    @gbroton 10 месяцев назад

    Business logic is not a domain logic. Separating domain logic from business (aka application) logic is the purest form of a clean architecture also called the onion architecture. The thing which you are calling "businesses logic" is the "application business rules" in the clean architecture picture. But great video in general showing the whole idea in a clear way.

  • @smokee_ms
    @smokee_ms 2 года назад

    Helpful intro to the topic. Much appreciated.

  • @fkondratov
    @fkondratov 9 месяцев назад

    good video, would be great if you had some kind of a series about architecture in general

  • @tarolee7323
    @tarolee7323 2 года назад

    This video is very helpful!!
    Hope you can give more concrete examples to help us understand the architecture more.
    Thanks again!

  • @MartinPerez-mi1ty
    @MartinPerez-mi1ty Год назад

    I finally understood the dp injection thank you

  • @joesmoo9254
    @joesmoo9254 Год назад

    outline: The speaker explains hexagonal architecture, also known as ports and adapters, and how it is used to protect business logic from changes in external sources. This architecture is beneficial in simplifying future changes to external dependencies, such as switching from MySQL to MongoDB. The speaker uses a pseudocode example of an Express app to demonstrate how to apply clean architecture, which involves decoupling business logic from external sources. The speaker emphasizes the importance of defining interfaces to pass in real implementations and avoiding tightly coupling to third-party dependencies or frameworks. The example includes removing Express-related code from the business function and creating a new file for database persistence.
    The speaker explains the implementation of clean architecture, which separates business functions from third-party dependencies. They show how to use dependency injection to achieve this, without getting caught in abstract concepts. They highlight the use of entities, which contain business rules and logic, and can be validated before being saved to the database. By using clean architecture and entities, the speaker suggests it is possible to structure code effectively and ensure it meets criteria. They advise viewers to use a framework or library to help with implementation.

  • @DigitalAlchemyst
    @DigitalAlchemyst Месяц назад

    Im still seeking those concrete examples because I am having trouble wrapping my brain around like what is the domain layer what is the business layer ( working in next now ) Hoping this clears things up more

  • @br3nto
    @br3nto 7 месяцев назад +1

    Clean Architecture has been going out of favour in the .Net world for a few key reasons. It requires a lot of code duplication and mapping to communicate between layers; functionality is hard to find because of abstract structuring; the previous two make refactoring extremely time consuming and tedious. A better architecture is vertical slices.

  • @DigitalAlchemyst
    @DigitalAlchemyst Месяц назад

    So part of the front end learning process, we do things like create json files with constants of various data, example a lot of portfolios essentially have a json resume that get mapped across the application in various ways.
    Would you say its safe to think of using this practice over having a big chunk of json at the top of the code that uses as the most micro implementation of clean arch? I see it as at least to a degree the code mapping the data in the portfolio has no knowledge ( or concern ) aside from the import of a json file or how the data is stored the code just gets data from else where. I have also gone through old projects built liked this and upgraded them to use a database with out having to change the presentation logic. of course even something that small could be broken down more like a pseduo DTO between the 2 or something.
    But I am just trying to see if i can think small and step my way up to a bigger understanding.

  • @wensmartsandy
    @wensmartsandy 9 месяцев назад

    Great video. Learned function injection. Thanks!

  • @iljushka7198
    @iljushka7198 2 года назад +1

    Probably it is all about dependency inversion principal you’ve told in this video. And this is only one part of Clean Architecture, like in-out ports

    • @WebDevCody
      @WebDevCody  2 года назад

      It’s hard to do true CA with a dynamically typed language. Something like typescript could setup interfaces for the ports, but js doesn’t support explicit interfaces; all interfaces are implicit. So the in port to the interactor is just the arguments passed in and the out port is what is returned

  • @abhiramkrishnam8825
    @abhiramkrishnam8825 Год назад

    Thanks dude this is an eye opener.

  • @balasuar
    @balasuar 10 месяцев назад

    My 2c's:
    Clean architectural pattern works if you know your business logic; said differently: it's a good choice when starting a project based on an existing product.
    Swapping out the database isn't something teams tend to do often--usually at the very early prototype stages, OR when sunsetting an MVP and moving to vNext.
    If entities implement enterprise logic (and typically requires persisting to a database), where should that logic live? Relationships between entities is often a function of foreign-key relationships across database tables. Does that then mean all enteprise logic lives in the database? Does that then mean enterprise logic by definition is only the type of logic that can be enforced by the database engine?

    • @WebDevCody
      @WebDevCody  10 месяцев назад

      I would keep all business logic out of the database. It’s ok to have some basic data integrity checks on your columns, but your code entities should verify a string field is an actual email, or an age isn’t negative and isn’t greater than 200, etc

  • @hakimbencella4242
    @hakimbencella4242 Год назад

    Thank you, Keep the good work!

  • @adanos2006
    @adanos2006 10 месяцев назад

    this video makes me subscribe

  • @KawtharAlekri
    @KawtharAlekri 6 месяцев назад

    Supet great and understandable!! Huge thanks 🙏🏻

  • @jf3594
    @jf3594 3 месяца назад

    This is how those things should be explained

  • @teamtosoz892
    @teamtosoz892 10 месяцев назад

    use cases are objects with their own request and and response objects

  • @joshuamangi6475
    @joshuamangi6475 2 года назад

    Hi there mate, thanks for this video. I am subscribing and hope you can dive deeper into this topic with maybe showcasing a small project with MongoDB and how this can be implemented. Great work though

  • @gincegeo
    @gincegeo 7 месяцев назад

    what is the best naming conventions? can you give us a repo we can refer?

  • @hosseinnajafi2181
    @hosseinnajafi2181 29 дней назад

    Thank you so much 🙏

  • @janschatz7223
    @janschatz7223 Год назад +1

    The separation between the Infrastructure and Interface Adapters layers is unclear to me. In which layer does createUserPersistence.js belong. It directly uses the database, which is infrastructure. So it can't be part of the Interface Adapters layer as it is not allowed to access the Infrastructure layer. But what is inside the Interface Adapters layer then?

  • @andreimclive
    @andreimclive Год назад

    FANTASTIC video. ThaNk you.

  • @nikk1019
    @nikk1019 7 месяцев назад

    This could be also done with CQRS pattern, i find it pretty convenient

  • @teerapatprommarak2070
    @teerapatprommarak2070 2 года назад

    Great explanation, thank you!

  • @guillaume5623
    @guillaume5623 11 месяцев назад

    This is gold

  • @kennedydre8074
    @kennedydre8074 Год назад

    This is amazing, thank you, if I wanted to use zod or joi for the validation how would I do it without actually requiring or importing the packages in the entities layer as those packages belong in the outer most ring?

  • @misterl8129
    @misterl8129 2 года назад

    very good video for get a little close to the CA. Maybe if you can do a next video showing like, the adaptor. So if for example i want to change between mysql to postgress, i dont need to change nothing inside the code besides the caller.
    Thank you!

    • @WebDevCody
      @WebDevCody  2 года назад +1

      The useCase should be able to call the same methods used to get data from the database. You should be able to just swap out the persistence methods at the higher level

  • @marcusrehn6915
    @marcusrehn6915 Год назад

    Regardless of the abstraction, any non trivial app is going to be hell to migrate from mysql to mongo or vice versa

  • @bilkisuismail6096
    @bilkisuismail6096 11 месяцев назад

    @webDevCody, i was wondering if you need interns in you work place. I would break a leg just to be mentored by you. You inspire me a lot.

  • @theoldknowledge6778
    @theoldknowledge6778 Год назад

    Excellent video. Btw, which VS Code theme is this?

  • @akay64x2
    @akay64x2 Год назад +1

    In what world switching from MySQL to MongoDB would take one line of code? They would not even have the same ORM layer. It will only be partially possible when using an ORM layer that supports the same type of DB as you want to swap and that also would be 80% coverage as for any nontrivial application, some queries will be written raw. - Just dropping this in here so someone wont get over sold or x or y architecture.

    • @WebDevCody
      @WebDevCody  Год назад +3

      The point is your business logic is decoupled from the code that accesses the database and those database access methods are injected as dependencies meaning you can potentially switch certain parts of your data models from one database to another. Your ORM would live in a persistence layer, it wouldn’t be one line so sorry if I said something dumb like that. The point was to make the code more decoupled and easier to refactor in the future

  • @judeclassic4179
    @judeclassic4179 2 года назад

    bro.. i love you thanks for the video

  • @dianrahmaji
    @dianrahmaji 2 года назад

    this video is really helpful!

  • @kaloianangelkov4919
    @kaloianangelkov4919 2 года назад

    Amazing explanation ! Got my sub !! :) Do you have any tutorials or videos where you speak about DTOs? (Data Transfer Object)
    I'd love to hear more about this.. :)

    • @WebDevCody
      @WebDevCody  2 года назад

      Not really, I have a recent video about clean arch but I don’t often use dots

  • @Jackinua
    @Jackinua Год назад

    Where will you put validation for Entity foreign key or Entity unique. Is it domain layer validation or iteration layer validation?

  • @alex-dk2rj
    @alex-dk2rj 2 года назад

    Great video, thanks.

  • @donnyroufs551
    @donnyroufs551 2 года назад +1

    Clean architecture is yechnically not an architecture. There is a reason that you cannot find a proper example by uncle bob himself. Its simply onion architecture with a few added principles.
    You missed the fact that dtos play a very important role since technically you are still coupled.
    I kind of dislike that people mention decoupling for ease of switching stuff because it barely happens... the biggest win imo is testability.
    Overall a great introduction to tease people their brains! We should collab someday.

    • @WebDevCody
      @WebDevCody  2 года назад +1

      Thanks for the comment! I think it’s good for both unit testing and swapping out modules in integration tests. Often when dealing with AWS there are a lot of services we interact with, so when running out integration tests in CI/CD or locally, we want to swap out the implementations to save files to local s3 mock services, mock dynamodb services etc. clean arch helps. But you’re right, often we don’t care to swap out our databases in the future.
      When you say dto, are you referring to the data Id be sending to the repository layer? Like in my example, createUserPersustence technically shouldn’t be passed the UserEntity, but instead a subset of necessary properties. But everything in JavaScript is an implied interface so it doesn’t matter too much as long as the object passed has the necessary properties on it.
      Send me any resource you have related to DTO. I think we might call the serializers or deserializers in our project. The things you run yours data through before you send it back from the API to the UI right?

    • @donnyroufs551
      @donnyroufs551 2 года назад

      @@WebDevCody Hey 👋
      Technically a repository is supposed to get the domain entity and from there on map it to a model that it needs to persist it to the database, so that part is completely fine! What I'm referring to is that you are using POJOs (simple objects) and just passing it the data, instead, it should be a DTO imho.
      Having a DTO makes it that an interactor doesn't have to know about the mapping, and gives the user / dev a contract to work with which allows for independence. I guess for sending an email you probably would create a factory E.g. emailFactory.createEmailResponse(User) which would return you a dto to pass to the email service.
      Khalil has very good stuff:
      khalilstemmler.com/articles/typescript-domain-driven-design/repository-dto-mapper/
      he's also in the middle of writing a book called "SOLID" not to mistake with the famous principles, its not done yet but it's to a point where it's worth a read. Anyway, mad respect for doing this kind of vids man! More developers need to get into this.
      edit:
      Should mention, after all its about trade-offs anyway. In a real world app we just pass a dto from controller to the repo and dont even care about entities because the amount of domain logic or need for completely being decoupled is not there.
      one of my projects that I stopped working on:
      github.com/donnyroufs/cofey/tree/develop/libs

    • @WebDevCody
      @WebDevCody  2 года назад

      @@donnyroufs551 Im not sure if I’m fully understanding. I could see the value when making a public api and you don’t have access to the clients consuming your api. In that case you’d want a contract to prevent your consumers to get changed data. (Unit and integration, or contract testing can verify this). On the project I’m on, if we update our entity, we also just go into the UI code and updates whatever might have changed. Usually the most that has changed is we added an additional property to an entity, so we don’t care if the ui is coupled to the api response because it’s just additional data coming back. I don’t see a value just yet for using a DTO between the business layer and persistence layer (or email function like you mentioned). The function is defined via an interface so the arguments are already coded to a contract.
      But yes, I agree most of all of this is a trade off. Adding all this “clean” design and abstraction makes the code a lot more complex to understand. We as engineers just need to know the pro and cons and apply these principles where we think they’d work best

    • @donnyroufs551
      @donnyroufs551 2 года назад

      @@WebDevCody Well a DTO is not just for your infra layer, it's to make sure you decouple layers and to move mapping to another place. Having a simple dto at controller level isnt enough if you want proper versioning either.

  • @kreyzor
    @kreyzor 2 года назад

    Amazing explanation!! Very Simple to understand and very straight forward!!

  • @canmertinyo
    @canmertinyo 4 месяца назад

    thanks

  • @shyraccoon4322
    @shyraccoon4322 2 года назад

    i think beginners should start with nest js ... it's hard for them to apply clean architecture in express and nest js forces them to do it

  • @dazzaondmic
    @dazzaondmic 2 года назад

    This is really informative, thank you! Quick question: what are some other benefits of implementing this kind of architecture apart from being able to easily swap out implementations? I'd like to advocate for this at my company but I don't feel like I have a strong enough argument to really vouch for it.

    • @WebDevCody
      @WebDevCody  2 года назад +1

      It can help with testing since it’s easier to mock out dependencies that are passed in instead of relying on a mocking library to achieve that. It also keeps the code base organized so all business logic exists in a similar place instead of it being sprinkled all throughout your code base. It takes discipline to double check you’re adding code to the correct layers.

    • @Ahmad-ww4ue
      @Ahmad-ww4ue 2 года назад

      Yeah testing is a big one. I've actually learned about dependency injection when we were trying to prevent tight coupling between classes so that each class can have its own unit tests written separately. That was why I understood the clean architecture approach that this video takes to dependency injection/inversion of control.

  • @santiagopabloortiz6322
    @santiagopabloortiz6322 2 года назад

    Pure gold.

  • @Cognitoman
    @Cognitoman Год назад

    I wanna try to do this with nest.js, I'm gonna use repository interface and have a repository class that implements that interface and uses typeorm, then for inside my service class I inject that repository by the interface, then later I can switch out the orm with another orm if I need too or use both it dont matter

  • @phamucmanh1750
    @phamucmanh1750 Год назад +1

    The one thing I am afraid of it is that code perfomance will be slower

  • @DuyTran-ss4lu
    @DuyTran-ss4lu Год назад

    wow, amazing!

  • @rachidb9624
    @rachidb9624 Год назад

    Thanks a lot !

  • @edu.paixao
    @edu.paixao Год назад

    Great example!
    Can you publish the code? Tks!

  • @SachinYadav-yx1rc
    @SachinYadav-yx1rc Год назад

    Would be great to know clean architecture in React app since its so unopinionated

  • @marcosmolina8606
    @marcosmolina8606 2 года назад

    Hi! I would ask if you don't think we can catch validation error before in some middleware. I use express-openapi and works very good.

    • @WebDevCody
      @WebDevCody  2 года назад

      You could do that, but I do think validation should be as close to your business entity as possible. It’s probably safe to validate the payload coming in, then also validate the entities as you change their properties

  • @codiction
    @codiction Год назад

    I need that theme!!!

  • @baremetals
    @baremetals Год назад

    Excellent.

  • @codenameich
    @codenameich 2 года назад

    thanks bro 🙏, any link on github for code in this video ?

  • @bollo_omar
    @bollo_omar 10 месяцев назад

    What theme are you using for the text editor

    • @WebDevCody
      @WebDevCody  10 месяцев назад +1

      Bearded theme stained blue

  • @SeibertSwirl
    @SeibertSwirl 2 года назад

    Good job babe!!

  • @qwertyntarantino1937
    @qwertyntarantino1937 Год назад

    @ what are you using for code completion? Your autocomplete plugins are way too far from what standard intellisense can offer

  • @sigitwasissubekti788
    @sigitwasissubekti788 7 месяцев назад

    get you share source code in github?

  • @andriisukhariev
    @andriisukhariev Год назад

    F*ing good. Do you have anything on clean architecture folder structure for small / mid / about to scale projects ? tthanks

    • @WebDevCody
      @WebDevCody  Год назад +1

      Not at the moment, I need to make a starter repo

    • @andriisukhariev
      @andriisukhariev Год назад

      ​@@WebDevCody looking forward. By the way - why do you have "require" instead of "import" - do you use older versions of node for a reason ? Also i found very little amount of tutorials on project structure when you have both static pages and API in one project.... might be interesting for you next tutor. Thanks!

  • @adrianmouzinho9615
    @adrianmouzinho9615 2 года назад +1

    Muito bom 🇧🇷

  • @chadjaasofianne310
    @chadjaasofianne310 5 месяцев назад

    if I would to do this pattern!, I will keep them all in the same file.

  • @jggabayno
    @jggabayno Год назад

    can u update this concept but with using prisma? :)

  • @tryCatchMeQWERTY
    @tryCatchMeQWERTY 4 месяца назад

    Uncle Bob === Robert Martin (why not just Uncle Rob?)😅

  • @jggabayno
    @jggabayno 2 года назад

    I have question, what if i want to validate if the user exist from database before calling a post request? how and where i can put the code, since in user entity it has validation without db code stuff.
    I wonder if its good to validate if user exist in createuserpersistence like this? hope it make sense.
    connection.query("SELECT * FROM users WHERE psid = '"+ psid +"'", (err : any, res : any) => {
    if(res.length === 0){
    // connection.query(`INSERT INTO users ....
    }
    })

    • @WebDevCody
      @WebDevCody  2 года назад +1

      I’d make a persistence method called getUser and you’d call it from the interactor. If getUser returns null, you can call the createUser persistence method. If the user exists, have the interactor throw an exception and your api layer would catch and return a 4xx status code

    • @jggabayno
      @jggabayno 2 года назад

      @@WebDevCody Got it. btw thank you for this awesome content. Also for your quick response. Appreciated

    • @jggabayno
      @jggabayno 2 года назад

      @@WebDevCody

      i dont know if its good to pass the res and getUser persistence to validate and send status in user entity. is it okay or bad?
      // user interactor
      await user.validate(getUserPersistence, res);

      const newUser = await createUserPersistence(user)
      return newUser
      // user entity
      async validate(getUserPersistence : any, res: any){
      const user: any = await getUserPersistence({psid: this.psid})
      if (user.length) {
      return res.status(409).send('User already Exist')
      } else if (!this.psid || !this.name || !this.email){
      return res.status(409).send('Improper Values')
      } else {
      return this;
      }
      }

    • @WebDevCody
      @WebDevCody  2 года назад

      @@jggabayno the interactor should not know about res at all. Also, I wouldn’t have your entity call the persistence method. Take the data returned from getUser and construct a new user entity using it, then validate the user entity

    • @WebDevCody
      @WebDevCody  2 года назад +1

      Join my discord for more help

  • @AdibPeerzade
    @AdibPeerzade Год назад

    Hi,Can you build a beginner tutorial of this?

  • @onuryildirim634
    @onuryildirim634 Год назад

    I can't find the repo link

  • @RealAshleyBailey
    @RealAshleyBailey 9 месяцев назад

    Okay but why on earth are you still using require and not import 🤨

  • @Ratstail91
    @Ratstail91 2 года назад

    ive never done this