{"id":13451901,"url":"https://github.com/zazoomauro/node-dependency-injection","last_synced_at":"2026-01-17T17:43:52.100Z","repository":{"id":16121497,"uuid":"79354548","full_name":"zazoomauro/node-dependency-injection","owner":"zazoomauro","description":"The NodeDependencyInjection component allows you to standarize and centralize the way objects are constructed in your application.","archived":false,"fork":false,"pushed_at":"2026-01-16T19:22:17.000Z","size":1867,"stargazers_count":291,"open_issues_count":7,"forks_count":35,"subscribers_count":6,"default_branch":"master","last_synced_at":"2026-01-16T23:36:37.130Z","etag":null,"topics":["dependency-injection","dependency-manager","es2015","es2016","es2017","es6","ioc","ioc-container","javascript","nodejs","service-injector","typescript"],"latest_commit_sha":null,"homepage":"https://github.com/zazoomauro/node-dependency-injection/wiki","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/zazoomauro.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG-2.md","contributing":"CONTRIBUTING.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-01-18T15:38:10.000Z","updated_at":"2026-01-16T19:21:30.000Z","dependencies_parsed_at":"2024-01-16T03:46:11.364Z","dependency_job_id":"5061ad74-f07e-420c-8383-fb17874d2044","html_url":"https://github.com/zazoomauro/node-dependency-injection","commit_stats":{"total_commits":303,"total_committers":20,"mean_commits":15.15,"dds":0.6963696369636964,"last_synced_commit":"cfe270e218d7c6523d08360fc75af5f844687b34"},"previous_names":[],"tags_count":108,"template":false,"template_full_name":null,"purl":"pkg:github/zazoomauro/node-dependency-injection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zazoomauro%2Fnode-dependency-injection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zazoomauro%2Fnode-dependency-injection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zazoomauro%2Fnode-dependency-injection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zazoomauro%2Fnode-dependency-injection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zazoomauro","download_url":"https://codeload.github.com/zazoomauro/node-dependency-injection/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zazoomauro%2Fnode-dependency-injection/sbom","scorecard":{"id":1238720,"data":{"date":"2025-07-07","repo":{"name":"github.com/zazoomauro/node-dependency-injection","commit":"cf7b236d440cc2d5a79a6b40798ecc211a770c11"},"scorecard":{"version":"v5.2.1-18-gbb9c347d","commit":"bb9c347dff6349d986baab6578a46d68a5524c62"},"score":3.7,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/build.yml:1","Warn: no topLevel permission defined: .github/workflows/publish.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 1/24 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":6,"reason":"dependency not pinned by hash detected -- score normalized to 6","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/zazoomauro/node-dependency-injection/build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/zazoomauro/node-dependency-injection/build.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/zazoomauro/node-dependency-injection/build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/zazoomauro/node-dependency-injection/build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/zazoomauro/node-dependency-injection/build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/zazoomauro/node-dependency-injection/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/zazoomauro/node-dependency-injection/publish.yml/master?enable=pin","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   3 out of   3 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENCE:0","Info: FSF or OSI recognized license: MIT License: LICENCE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#license"}},{"name":"Packaging","score":10,"reason":"packaging workflow detected","details":["Info: Project packages its releases by way of GitHub Actions.: .github/workflows/publish.yml:8"],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#packaging"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 11 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":5,"reason":"5 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-10-10T13:57:29.531Z","repository_id":16121497,"created_at":"2025-10-10T13:57:29.538Z","updated_at":"2025-10-10T13:57:29.538Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28513973,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T13:38:16.342Z","status":"ssl_error","status_checked_at":"2026-01-17T13:37:44.060Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-injection","dependency-manager","es2015","es2016","es2017","es6","ioc","ioc-container","javascript","nodejs","service-injector","typescript"],"created_at":"2024-07-31T07:01:06.371Z","updated_at":"2026-01-17T17:43:52.087Z","avatar_url":"https://github.com/zazoomauro.png","language":"JavaScript","readme":"Node Dependency Injection\n=========================\n\n![NDI Logo](http://image.ibb.co/iGnCUn/logojoy.png)\n\n#### A special thanks to [Symfony](http://symfony.com) which was a great inspiration and example for this project.\n\nThe Node Dependency Injection component allows you to standardize and centralize the way objects are constructed in your application.\n\n[![Npm Version](https://badge.fury.io/js/node-dependency-injection.svg)](https://badge.fury.io/js/node-dependency-injection)\n![Build Status](https://github.com/zazoomauro/node-dependency-injection/actions/workflows/build.yml/badge.svg)\n![Publish Status](https://github.com/zazoomauro/node-dependency-injection/actions/workflows/publish.yml/badge.svg)\n[![Code Coverage](https://codecov.io/gh/zazoomauro/node-dependency-injection/branch/master/graph/badge.svg?token=faEAqrimPR)](https://codecov.io/gh/zazoomauro/node-dependency-injection)\n[![Coding Standard](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)\n[![Known Vulnerabilities](https://snyk.io/test/github/zazoomauro/node-dependency-injection/badge.svg)](https://snyk.io/test/github/zazoomauro/node-dependency-injection)\n[![Npm Downloads](https://img.shields.io/npm/dm/node-dependency-injection.svg?maxAge=2592000)](https://www.npmjs.com/package/node-dependency-injection)\n[![License](https://img.shields.io/npm/l/node-dependency-injection.svg?maxAge=2592000?style=plastic)](https://github.com/zazoomauro/node-dependency-injection/blob/master/LICENCE)\n\nInstallation\n------------\n\n```sh\nnpm install --save node-dependency-injection\n```\n\nUsage: register and get services\n-----------\n\nImagine you have a `Mailer` class like this:\n\n```js\n// services/Mailer.js\n\nexport default class Mailer {\n  /**\n   * @param {ExampleService} exampleService\n   */\n  constructor(exampleService) {\n    this._exampleService = exampleService;\n  }\n\n  ...\n}\n```\n\nYou can register this in the container as a service:\n\n```js\nimport {ContainerBuilder} from 'node-dependency-injection'\nimport Mailer from './services/Mailer'\nimport ExampleService from './services/ExampleService'\n\nlet container = new ContainerBuilder()\n\ncontainer\n  .register('service.example', ExampleService)\n\ncontainer\n  .register('service.mailer', Mailer)\n  .addArgument('service.example')\n```\n\nAnd get services from your container\n\n```js\nconst mailer = container.get('service.mailer')\n```\n\nAutowire for TypeScript\n------------\n\n```ts\nimport {ContainerBuilder, Autowire} from 'node-dependency-injection'\n\nconst container = new ContainerBuilder(\n  false, \n  '/path/to/src'\n)\nconst autowire = new Autowire(container)\nawait autowire.process()\n\n```\n\nor from yaml-json-js configuration\n\n```yaml\n# /path/to/services.yml\nservices:\n  _defaults:\n    autowire: true\n    rootDir:  \"/path/to/src\"\n```\n\nYou can also get a service from a class definition\n\n```ts\nimport SomeService from '@src/service/SomeService'\n\ncontainer.get(SomeService)\n```\n\nIf you are transpiling your Typescript may you need to dump the some kind of service configuration file.\n\n```ts\nimport {ContainerBuilder, Autowire, ServiceFile} from 'node-dependency-injection'\n\nconst container = new ContainerBuilder(\n  false, \n  '/path/to/src'\n)\nconst autowire = new Autowire(container)\nautowire.serviceFile = new ServiceFile('/some/path/to/dist/services.yaml')\nawait autowire.process()\n\n```\n\nMy proposal for load configuration file in a production environment with transpiling/babel compilation:\n\n```ts\nif (process.env.NODE_ENV === 'dev') {\n  this._container = new ContainerBuilder(false, '/src');\n  this._autowire = new Autowire(this._container);\n  this._autowire.serviceFile = new ServiceFile('/some/path/to/dist/services.yaml');\n  await this._autowire.process();\n} else {\n  this._container = new ContainerBuilder(false, '/dist');\n  this._loader = new YamlFileLoader(this._container);\n  await this._loader.load('/some/path/to/dist/services.yaml');\n}\nawait this._container.compile();\n```\n\n\nConfiguration files: how to load and use configuration files\n------------\n\nYou can also use configuration files to improve your service configuration\n\n```yaml\n# /path/to/file.yml\nservices:\n  service.example:\n    class: 'services/ExampleService'\n\n  service.mailer:\n    class: 'services/Mailer'\n    arguments: ['@service.example']\n```\n\n```js\nimport {ContainerBuilder, YamlFileLoader} from 'node-dependency-injection'\n\nlet container = new ContainerBuilder()\nlet loader = new YamlFileLoader(container)\nawait loader.load('/path/to/file.yml')\n```\n\nAnd get services from your container easily\n\n```js\n...\nconst mailer = container.get('service.mailer')\n```\n\nList of features\n------------\n\n- Autowire for TypeScript\n- Configuration files with JS, YAML or JSON.\n- Multiple configuration files\n- Custom relative service directory\n- Compiling container\n  - Custom compiler pass\n  - Change definition behaviour\n- Using a factory to create services\n- Nullable Dependencies\n- Public or private services\n- Service Aliasing\n- Service Tagging\n- Parameters Injection\n- Lazy Services\n- Deprecate Services\n- Decorate Services\n- Synthetic Services\n- Non Shared Services\n- Parent and Abstract Services\n- Custom Logger\n- Container as Service\n\n\u003e Please read [full documentation](https://github.com/zazoomauro/node-dependency-injection/wiki)\n\nExpressJS Usage\n----------------\n\nIf you are using expressJS and you like Node Dependency Injection Framework then I strongly recommend\nyou to use the `node-dependency-injection-express-middleware` package.\nThat gives you the possibility to retrieve the container from the request.\n\n```bash\nnpm install --save node-dependency-injection-express-middleware\n```\n\n```javascript\nimport NDIMiddleware from 'node-dependency-injection-express-middleware'\nimport express from 'express'\n\nconst app = express()\n\nconst options = {serviceFilePath: 'some/path/to/config.yml'}\napp.use(new NDIMiddleware(options).middleware())\n```\n\n\u003e [Express Middleware Documentation](https://github.com/zazoomauro/node-dependency-injection-express-middleware)\n\nTypeScript Usage\n----------------\n\nIf you are using typescript and you like Node Dependency Injection Framework then typing are now provided at `node-dependency-injection` so \nyou do not have to create custom typing anymore.\n\n```bash\nnpm install --save node-dependency-injection\n```\n\n```typescript\nimport { ContainerBuilder } from 'node-dependency-injection'\nimport MongoClient from './services/MongoClient'\nimport { Env } from './EnvType'\n\nexport async function boot(container = new ContainerBuilder(), env: Env) {\n    container.register('Service.MongoClient', MongoClient).addArgument({\n        host: env.HOST,\n        port: env.PORT,\n    })\n}\n```\n\nResources\n---------\n\n- [Documentation](https://github.com/zazoomauro/node-dependency-injection/wiki)\n- [Collaboration and pull requests](CONTRIBUTING.md)\n- [Milestones](https://github.com/zazoomauro/node-dependency-injection/milestones)\n- [Twitter @zazoomauro](https://twitter.com/zazoomauro)\n- [Changelog](CHANGELOG.md)\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzazoomauro%2Fnode-dependency-injection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzazoomauro%2Fnode-dependency-injection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzazoomauro%2Fnode-dependency-injection/lists"}