{"id":20442968,"url":"https://github.com/mrbrunelli/dependency-inversion-principle","last_synced_at":"2026-05-30T18:31:01.054Z","repository":{"id":122801646,"uuid":"311972978","full_name":"mrbrunelli/dependency-inversion-principle","owner":"mrbrunelli","description":"Exemplo utilizando o Princípio da Inversão de Dependência","archived":false,"fork":false,"pushed_at":"2020-11-12T10:01:23.000Z","size":29,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-05T08:17:57.645Z","etag":null,"topics":["dependency-inversion","solid","solid-principles","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrbrunelli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-11T13:05:13.000Z","updated_at":"2022-02-25T18:29:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"6848c2a6-3218-415c-bd03-f448ec2a2969","html_url":"https://github.com/mrbrunelli/dependency-inversion-principle","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mrbrunelli/dependency-inversion-principle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrbrunelli%2Fdependency-inversion-principle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrbrunelli%2Fdependency-inversion-principle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrbrunelli%2Fdependency-inversion-principle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrbrunelli%2Fdependency-inversion-principle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrbrunelli","download_url":"https://codeload.github.com/mrbrunelli/dependency-inversion-principle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrbrunelli%2Fdependency-inversion-principle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33705207,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-30T02:00:06.278Z","response_time":92,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dependency-inversion","solid","solid-principles","typescript"],"created_at":"2024-11-15T09:43:34.941Z","updated_at":"2026-05-30T18:31:01.037Z","avatar_url":"https://github.com/mrbrunelli.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# :cool: Dependency Inversion\n\u003e Princípio da Inversão de Dependência - **Dependa de abstrações e não de implementações.**\n\n### De acordo com Uncle Bob, esse princípio pode ser definido da seguinte forma\n1. Módulos de alto nível não devem depender de módulos de baixo nível. Ambos devem depender da abstração.\n2. Abstrações não devem depender de detalhes. Detalhes devem depender de abstrações.\n\n### É comum\nGeralmente utilizamos várias bibliotecas em nossos projetos, até ai tudo bem, tudo que puder facilitar nosso trabalho será sempre bem vindo. O único problema é quando ficamos presos a essas bibliotecas, e mudar começa a ficar muito custoso.\n\n### Exemplos\nUtilizei a biblioteca Axios que faz requisições Http para exemplificar o caso.\n##### Sem princípios\n\u003e Nosso Controller é responsável por criar instâncias de bibliotecas externas. Causando alto acoplamento.\n![](./docs/no-principle.png)\n\n##### Com princípios\n\u003e Nosso Controller não sabe qual biblioteca estamos utilizando. Ele só precisa receber uma classe que faça requisições Http. Dessa forma nós invertemos a dependência.\n![](./docs/dependency-inversion.png)\n\n### Como executar?\n```bash\nnpm install \u0026\u0026 npm run dev\n```\n\n### Créditos\n:link: [#1 SOLID Principles \u0026 Design Patterns - Rodrigo Manguinho](https://www.youtube.com/watch?v=LTb89krmBP0\u0026t=698s\u0026ab_channel=Mango)\n\n:link: [O que é SOLID - João Roberto da Paixão](https://medium.com/desenvolvendo-com-paixao/o-que-%C3%A9-solid-o-guia-completo-para-voc%C3%AA-entender-os-5-princ%C3%ADpios-da-poo-2b937b3fc530)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrbrunelli%2Fdependency-inversion-principle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrbrunelli%2Fdependency-inversion-principle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrbrunelli%2Fdependency-inversion-principle/lists"}