{"id":16234685,"url":"https://github.com/sielay/ditoolkit","last_synced_at":"2025-07-15T22:08:26.483Z","repository":{"id":57213117,"uuid":"64672923","full_name":"sielay/ditoolkit","owner":"sielay","description":"Set of classes and helpers for dependency injection in NodeJS","archived":false,"fork":false,"pushed_at":"2016-08-01T15:51:29.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-17T05:19:30.072Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sielay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-01T14:17:10.000Z","updated_at":"2016-08-01T15:51:30.000Z","dependencies_parsed_at":"2022-08-24T21:41:50.454Z","dependency_job_id":null,"html_url":"https://github.com/sielay/ditoolkit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sielay/ditoolkit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sielay%2Fditoolkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sielay%2Fditoolkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sielay%2Fditoolkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sielay%2Fditoolkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sielay","download_url":"https://codeload.github.com/sielay/ditoolkit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sielay%2Fditoolkit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265463846,"owners_count":23770300,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-10-10T13:16:47.532Z","updated_at":"2025-07-15T22:08:26.431Z","avatar_url":"https://github.com/sielay.png","language":"JavaScript","readme":"# DIToolkit\n\n## Problem\n\nThere are various projects solving dependency injection for NodeJS. All of them are quire opinioneted and most apply Angular way - where target of injection decide about dependencies and they can be overriden in some config.\n\nAlso non of them appreciate that DI is most useful in node for promised/deferred dependencis.\n\n## Installation\n\n```sh\nnpm i --save ditoolkit\n```\n\n## Usage\n\n### Functions - on example of Express Middleware\n\n```javascript\n// module1\n\nmodule.export = function IWantToBeTestable(dependency1, dependancy2, dependancy3, req, res, next, id) {\n    ...\n}\n\n// module 2\nconst module1 = require('./module1');\nrequire('ditoolkit');\n\napp.user(module1.injected(null, 123, {config:1}, Promise.resolve('whatever')));\n\n```\n\nMethod `injected` and it synchronous version (not supporting promises) `inject` are added to `Function` prototype. Once you call them you'd get version of the function with bound `thisArg` and dependencies. Dependencies will be prefixed to later arguments (like you can see in function declaration).\n\n### Classes\n\n```javascript\n\nconst DI = require('ditoolkit');\n\nclass A {\n    test(depencency1, someArg) { ... }\n}\n\nlet a = new A();\n\nDI.decorate(a, [sharedDependnecy1]);\n\nclass B {\n    test() { ... },\n    test2(dependency1) { ... },\n    test3(dependency1, dependency2, someArg) { ... }\n}\n\nlet B = new A();\n\nDI.decorate(a, [sharedDependnecy1], {\n    test2: [],\n    test3: [sharedDepenency2]\n});\n\n\n```\n\n### Also\n\nSee test for details.\n\n## License\n\nMIT\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsielay%2Fditoolkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsielay%2Fditoolkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsielay%2Fditoolkit/lists"}