{"id":42227284,"url":"https://github.com/matuszeman/bb-dic","last_synced_at":"2026-01-27T02:37:00.067Z","repository":{"id":57123918,"uuid":"65415319","full_name":"matuszeman/bb-dic","owner":"matuszeman","description":"A dependency injection container for JavaScript.","archived":false,"fork":false,"pushed_at":"2019-04-10T06:49:58.000Z","size":191,"stargazers_count":4,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-20T05:28:18.406Z","etag":null,"topics":["bb-dic","dependency-injection","dependency-injection-container","dic","inversion-of-control"],"latest_commit_sha":null,"homepage":"","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/matuszeman.png","metadata":{"files":{"readme":"README.hbs.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-10T20:45:26.000Z","updated_at":"2019-04-10T06:50:00.000Z","dependencies_parsed_at":"2022-08-27T12:00:49.810Z","dependency_job_id":null,"html_url":"https://github.com/matuszeman/bb-dic","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/matuszeman/bb-dic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matuszeman%2Fbb-dic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matuszeman%2Fbb-dic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matuszeman%2Fbb-dic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matuszeman%2Fbb-dic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matuszeman","download_url":"https://codeload.github.com/matuszeman/bb-dic/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matuszeman%2Fbb-dic/sbom","scorecard":{"id":628252,"data":{"date":"2025-08-11","repo":{"name":"github.com/matuszeman/bb-dic","commit":"74f0fdf92ae074ae1f064e5fcbe3a55753fbd6b3"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"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/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"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/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 1/29 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/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"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/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/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/f6ed084d17c9236477efd66e5b258b9d4cc7b389/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/f6ed084d17c9236477efd66e5b258b9d4cc7b389/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/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"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/f6ed084d17c9236477efd66e5b258b9d4cc7b389/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/f6ed084d17c9236477efd66e5b258b9d4cc7b389/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 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"42 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx","Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-9vvw-cc9w-f27h","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-hr2v-3952-633q","Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9","Warn: Project is vulnerable to: GHSA-qh2h-chj9-jffq","Warn: Project is vulnerable to: GHSA-q42p-pg8m-cqh6","Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv","Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8","Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65","Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh","Warn: Project is vulnerable to: GHSA-w457-6q6x-cgp9","Warn: Project is vulnerable to: GHSA-9prh-257w-9277","Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44","Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988","Warn: Project is vulnerable to: GHSA-jp4x-w63m-7wgm","Warn: Project is vulnerable to: GHSA-c429-5p7v-vgjp","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-fvqr-27wr-82fm","Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574","Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-p9wx-2529-fp83","Warn: Project is vulnerable to: GHSA-5v2h-r2cx-5xgj","Warn: Project is vulnerable to: GHSA-rrrm-qjm4-v8hf","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-6g33-f262-xjp4","Warn: Project is vulnerable to: GHSA-mxhp-79qh-mcx6","Warn: Project is vulnerable to: GHSA-34r7-q49f-h37c","Warn: Project is vulnerable to: GHSA-c9f4-xj24-8jqx","Warn: Project is vulnerable to: GHSA-cf4h-3jhx-xvhq"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-21T07:08:08.525Z","repository_id":57123918,"created_at":"2025-08-21T07:08:08.525Z","updated_at":"2025-08-21T07:08:08.525Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28796984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T01:07:07.743Z","status":"online","status_checked_at":"2026-01-27T02:00:07.755Z","response_time":168,"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":["bb-dic","dependency-injection","dependency-injection-container","dic","inversion-of-control"],"created_at":"2026-01-27T02:36:59.046Z","updated_at":"2026-01-27T02:37:00.059Z","avatar_url":"https://github.com/matuszeman.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bb-dic\n\n[![Build Status](https://travis-ci.org/matuszeman/bb-dic.svg?branch=master)](https://travis-ci.org/matuszeman/bb-dic)\n\nA dependency injection container with async support.\n\n# Installation\n\n```\nnpm install @kapitchi/bb-dic\n```\n\n# Usage\n\nFor ES5/ES6 compatible implementation use `require('@kapitchi/bb-dic/es5')`.\n\nDIC uses [acorn](https://www.npmjs.com/package/acorn) to parse the code to discover function parameters.  \nIf you encounter parsing issues try to fiddle with `ecmaVersion` parameter (default 8).\n\nSee `examples` folder for full usage examples.\n\nFramework usage examples can be found [at the bottom](#framework-usage-examples).\n\n## Sync usage\n\n```\nclass MyService {\n  constructor(myServiceOpts) {\n    this.options = myServiceOpts;\n  }\n\n  showOff() {\n    console.log('My options are:', this.options);\n  }\n}\n\nconst {Dic} = require('@kapitchi/bb-dic');\nconst dic = new Dic();\n\n// register all instances\ndic.instance('myServiceOpts', { some: 'thing' });\ndic.class('myService', MyService);\ndic.factory('myApp', function(myService) {\n  return function() {\n    // some application code\n    myService.showOff();\n  }\n});\n\n// use it\nconst app = dic.get('myApp');\napp();\n```\n\n## Async usage\n\nUse when one of your class instances or instance factories needs async initialization.\n```\nconst {Dic} = require('@kapitchi/bb-dic');\nconst dic = new Dic();\n\nclass AsyncService {\n  async asyncInit() {\n    // some async await calls\n  }\n\n  showOff() {\n    console.log('Perfect, all works!');\n  }\n}\ndic.class('asyncService', AsyncService);\n\ndic.asyncFactory('asyncMsg', async function() {\n  // some async calls needed to create an instance of this service\n  return 'Async helps the server.';\n})\n\ndic.factory('myApp', function(asyncService, asyncMsg) {\n  return function() {\n    // some application code with all services ready\n    myService.showOff();\n    console.log(asyncMsg);\n  }\n});\n\n// Creates myApp service and instantiate all its direct dependencies\ndic.getAsync('myApp').then(app =\u003e {\n  app();\n});\n```\n\n\n# API\n\n{{\u003emain}}\n\n# Framework usage examples\n\nRun on NodeJS 7.* with `--harmony` flag\n\n## [Koa](http://koajs.com/)\n```\nconst Koa = require('koa');\nconst {Dic} = require('@kapitchi/bb-dic');\n\nconst dic = new Dic();\ndic.instance('functionMiddlewareOpts', { returnString: 'Hello World' });\n\ndic.factory('functionMiddleware', function(functionMiddlewareOpts) {\n  return async (ctx) =\u003e {\n    console.log('functionMiddleware \u003e before');//XXX\n    ctx.body = functionMiddlewareOpts.returnString;\n    console.log('functionMiddleware \u003e after');//XXX\n  }\n});\n\ndic.class('classMiddleware', class ClassMiddleware {\n  async asyncInit() {\n    // some async initialization\n  }\n\n  async middlewareOne(ctx, next) {\n    console.log('classMiddleware.middlewareOne \u003e before');//XXX\n    await next();\n    console.log('classMiddleware.middlewareOne \u003e after');//XXX\n  }\n});\n\ndic.factory('app', function(\n  classMiddleware,\n  functionMiddleware\n) {\n  const app = new Koa();\n\n  app.use(classMiddleware.middlewareOne);\n  app.use(functionMiddleware);\n\n  return app;\n});\n\n(async () =\u003e {\n  const app = await dic.getAsync('app');\n  app.listen(3000);\n  console.log('Running at: http://localhost:3000');\n})();\n```\n\n## [Hapi](https://hapijs.com/)\n```\nconst Hapi = require('hapi');\nconst {Dic} = require('@kapitchi/bb-dic');\n\nconst dic = new Dic();\ndic.instance('functionHandlerOpts', {\n  response: {\n    msg: 'Hello from function handler'\n  }\n});\ndic.instance('classHandlerOpts', {\n  response: {\n    msg: 'Hello from class handler'\n  }\n});\n\ndic.factory('functionHandler', function (functionHandlerOpts) {\n  return async (request, reply) =\u003e {\n    reply(functionHandlerOpts.response);\n  }\n});\n\ndic.class('classHandler', class ClassHandler {\n  constructor(classHandlerOpts) {\n    this.options = classHandlerOpts;\n  }\n\n  async asyncInit() {\n    // some async initialization\n  }\n\n  async handler(request, reply) {\n    reply(this.options.response);\n  }\n});\n\ndic.factory('server', function(\n  functionHandler,\n  classHandler\n) {\n  const server = new Hapi.Server();\n  server.register([\n    require('hapi-async-handler')\n  ], function(err) {\n    if (err) {\n      throw err;\n    }\n  });\n\n  server.connection({\n    host: 'localhost',\n    port: 8000\n  });\n\n  server.route({\n    method: 'GET',\n    path: '/func',\n    handler: functionHandler\n  });\n\n  server.route({\n    method: 'GET',\n    path: '/class',\n    handler: classHandler.handler.bind(classHandler)\n  });\n\n  return server;\n});\n\n(async () =\u003e {\n  server = await dic.getAsync('server');\n  await server.start();\n  console.log('Server running at:', server.info.uri);\n})();\n```\n\n# Development\n\nRun the command below to builds es5 folder and README.md.\n\n```\nnpm run build\n```\n\n## Tests\n\n```\nnpm test\n```\n\n# Contribute\n\nPlease feel free to submit an issue/PR or contact me at matus.zeman@gmail.com.\n\n# License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatuszeman%2Fbb-dic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatuszeman%2Fbb-dic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatuszeman%2Fbb-dic/lists"}