{"id":13661018,"url":"https://github.com/wookieb/alpha-dic","last_synced_at":"2025-04-10T16:22:59.378Z","repository":{"id":51909520,"uuid":"77154704","full_name":"wookieb/alpha-dic","owner":"wookieb","description":"Powerful dependency injection container for node.js","archived":false,"fork":false,"pushed_at":"2024-01-22T20:14:42.000Z","size":837,"stargazers_count":27,"open_issues_count":9,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T16:44:09.762Z","etag":null,"topics":["alpha-packages","dependency-injection","dependency-injection-container","ioc","ioc-container","javascript","nodejs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/wookieb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2016-12-22T15:20:51.000Z","updated_at":"2024-01-22T20:14:47.000Z","dependencies_parsed_at":"2024-06-29T19:52:23.852Z","dependency_job_id":"ef86d66e-6589-433e-88d6-866573b18444","html_url":"https://github.com/wookieb/alpha-dic","commit_stats":{"total_commits":68,"total_committers":3,"mean_commits":"22.666666666666668","dds":"0.19117647058823528","last_synced_commit":"5b94b7cc8256829534a83a8a892f4c6a33ccdd22"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wookieb%2Falpha-dic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wookieb%2Falpha-dic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wookieb%2Falpha-dic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wookieb%2Falpha-dic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wookieb","download_url":"https://codeload.github.com/wookieb/alpha-dic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248199136,"owners_count":21063641,"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":["alpha-packages","dependency-injection","dependency-injection-container","ioc","ioc-container","javascript","nodejs"],"created_at":"2024-08-02T05:01:28.648Z","updated_at":"2025-04-10T16:22:59.341Z","avatar_url":"https://github.com/wookieb.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Alpha DIC\n\n[![CircleCI](https://travis-ci.org/wookieb/alpha-dic.svg?branch=master)](https://travis-ci.org/wookieb/alpha-dic)\n[![Coverage Status](https://coveralls.io/repos/github/wookieb/alpha-dic/badge.svg?branch=master)](https://coveralls.io/github/wookieb/alpha-dic?branch=master)\n\nFlexible Dependency Injection Container with support for asynchronous service creation, annotations and middlewares.\n\nFeatures:\n* Autowiring\n* Supports middlewares\n* Allows to define service as constructor, (async) factory or a value\n* Detects cycle dependencies\n* Prevents race condition for concurrent service requests\n* Supports annotations (and ability to search services by annotations)\n* Simple service definition via container methods or decorators\n\n# Installation\n```bash\nnpm install alpha-dic\n```\n\n# Example\n```typescript\nimport {createStandard} from 'alpha-dic';\n\nconst container = createStandard();\n// if you're defining services via decorators\n// preloadServiceModules(container, './path/to/service/modules/*')\n\ncontainer.definitionWithFactory('my-service', async () =\u003e {\n        const connection = new DatabaseConnection();\n        await connection.connect();\n        return connection;\n    });\n\ncontainer.get('my-service').then((connection) =\u003e {\n    // connection has been established in factory\n});\n\n```\n\nExample with dependencies and decorators\n```typescript\nimport {createStandard, reference, AutowiredService, Service, OnActivation} from 'alpha-dic';\nimport * as assert from 'assert';\n\nconst container = createStandard();\n\n@AutowiredService('NotificationCenter')\nclass NotificationCenter {\n    constructor(renderer: EmailRenderer, sender: EmailSender) {\n        assert.ok(renderer instanceof EmailRenderer);\n        // connection to SMTP was established in factory\n        assert.ok(sender instanceof EmailSender);\n    }\n    async sendEmail(to, type, vars) {\n        // render email\n        // send it via sender\n    }\n}\n\n@Service()\nclass EmailRenderer {\n    \n}\n\n@Service()\n@OnActivation(async (mailer) =\u003e {\n    await mailer.connectToSMTP();\n    return mailer;\n})\nclass EmailSender {\n    \n}\n\ncontainer.get('NotificationCenter')\n    .then((centre) =\u003e {\n        return centre.sendEmail('admin@example.com', 'limits-exceeded', {})\n    })\n```\n\n* [Simple usage rules](./docs/rules.md)\n* [Defining services](./docs/defining-services.md)\n* [Decorators](./docs/decorators.md)\n* [Annotations](./docs/annotations.md)\n* [Middlewares](./docs/middlewares.md)\n* [Hierarchical container](./docs/hierarchical-di.md)\n* [Injecting configuration values](./docs/configuration.md)\n* [Hooks - @OnActivation, onActivation](./docs/on-activation.md)\n* [Deprecating services](./docs/deprecating.md)\n* [Autowiring](./docs/autowiring.md)\n* [Big projects tips](./docs/big-project-tips.md)\n* [Example](./example)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwookieb%2Falpha-dic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwookieb%2Falpha-dic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwookieb%2Falpha-dic/lists"}