{"id":13452491,"url":"https://github.com/typestack/typedi","last_synced_at":"2025-05-13T20:22:43.379Z","repository":{"id":37677889,"uuid":"43365671","full_name":"typestack/typedi","owner":"typestack","description":"Simple yet powerful dependency injection tool for JavaScript and TypeScript.","archived":false,"fork":false,"pushed_at":"2025-05-07T08:57:52.000Z","size":3671,"stargazers_count":4150,"open_issues_count":55,"forks_count":169,"subscribers_count":31,"default_branch":"develop","last_synced_at":"2025-05-07T10:35:29.478Z","etag":null,"topics":["dependency-injection","inversion-of-control","ioc","typedi","typescript"],"latest_commit_sha":null,"homepage":"https://docs.typestack.community/typedi/v/develop/01-getting-started","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/typestack.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,"zenodo":null}},"created_at":"2015-09-29T12:23:30.000Z","updated_at":"2025-05-05T23:04:38.000Z","dependencies_parsed_at":"2023-10-16T18:28:40.377Z","dependency_job_id":"4cc83307-e106-4939-9575-06492f646e08","html_url":"https://github.com/typestack/typedi","commit_stats":{"total_commits":1221,"total_committers":29,"mean_commits":42.10344827586207,"dds":"0.18263718263718265","last_synced_commit":"7c6ac12a3de8507b1306f761942562f15375ed1f"},"previous_names":["pleerock/typedi"],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typestack%2Ftypedi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typestack%2Ftypedi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typestack%2Ftypedi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typestack%2Ftypedi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/typestack","download_url":"https://codeload.github.com/typestack/typedi/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253154977,"owners_count":21862623,"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":["dependency-injection","inversion-of-control","ioc","typedi","typescript"],"created_at":"2024-07-31T07:01:25.700Z","updated_at":"2025-05-13T20:22:38.334Z","avatar_url":"https://github.com/typestack.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","目录","Libraries","\u003ca name=\"TypeScript\"\u003e\u003c/a\u003eTypeScript"],"sub_categories":["TypeScript"],"readme":"# TypeDI\n\n![Build Status](https://github.com/typestack/typedi/workflows/CI/badge.svg)\n[![codecov](https://codecov.io/gh/typestack/typedi/branch/master/graph/badge.svg)](https://codecov.io/gh/typestack/typedi)\n[![npm version](https://badge.fury.io/js/typedi.svg)](https://badge.fury.io/js/typedi)\n[![Dependency Status](https://david-dm.org/typestack/typedi.svg)](https://david-dm.org/typestack/typedi)\n\nTypeDI is a [dependency injection](https://en.wikipedia.org/wiki/Dependency_injection) tool for TypeScript and JavaScript. With it you can build well-structured and easily testable applications in Node or in the browser.\n\nMain features includes:\n\n- property based injection\n- constructor based injection\n- singleton and transient services\n- support for multiple DI containers\n\n## Installation\n\n\u003e Note: This installation guide is for usage with TypeScript, if you wish to use\n\u003e TypeDI without Typescript please read the documentation about how get started.\n\nTo start using TypeDI install the required packages via NPM:\n\n```bash\nnpm install typedi reflect-metadata\n```\n\nImport the `reflect-metadata` package at the **first line** of your application:\n\n```ts\nimport 'reflect-metadata';\n\n// Your other imports and initialization code\n// comes here after you imported the reflect-metadata package!\n```\n\nAs a last step, you need to enable emitting decorator metadata in your Typescript config. Add these two lines to your `tsconfig.json` file under the `compilerOptions` key:\n\n```json\n\"emitDecoratorMetadata\": true,\n\"experimentalDecorators\": true,\n```\n\nNow you are ready to use TypeDI with Typescript!\n\n## Basic Usage\n\n```ts\nimport { Container, Service } from 'typedi';\n\n@Service()\nclass ExampleInjectedService {\n  printMessage() {\n    console.log('I am alive!');\n  }\n}\n\n@Service()\nclass ExampleService {\n  constructor(\n    // because we annotated ExampleInjectedService with the @Service()\n    // decorator TypeDI will automatically inject an instance of\n    // ExampleInjectedService here when the ExampleService class is requested\n    // from TypeDI.\n    public injectedService: ExampleInjectedService\n  ) {}\n}\n\nconst serviceInstance = Container.get(ExampleService);\n// we request an instance of ExampleService from TypeDI\n\nserviceInstance.injectedService.printMessage();\n// logs \"I am alive!\" to the console\n```\n\n## Documentation\n\nThe detailed usage guide and API documentation for the project can be found:\n\n- at [docs.typestack.community/typedi][docs-stable]\n- in the `./docs` folder of the repository\n\n[docs-stable]: https://docs.typestack.community/typedi/\n[docs-development]: https://docs.typestack.community/typedi/v/develop/\n\n## Contributing\n\nPlease read our [contributing guidelines](./CONTRIBUTING.md) to get started.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypestack%2Ftypedi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftypestack%2Ftypedi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypestack%2Ftypedi/lists"}