{"id":21095436,"url":"https://github.com/faebeee/servicecontainer","last_synced_at":"2026-04-26T17:32:01.507Z","repository":{"id":65494599,"uuid":"76071949","full_name":"faebeee/servicecontainer","owner":"faebeee","description":null,"archived":false,"fork":false,"pushed_at":"2018-12-06T22:54:42.000Z","size":500,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-31T05:00:08.962Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://faebeee.github.io/servicecontainer/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/faebeee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-09T21:35:30.000Z","updated_at":"2018-12-06T22:54:44.000Z","dependencies_parsed_at":"2023-01-26T03:46:03.829Z","dependency_job_id":null,"html_url":"https://github.com/faebeee/servicecontainer","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/faebeee/servicecontainer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faebeee%2Fservicecontainer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faebeee%2Fservicecontainer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faebeee%2Fservicecontainer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faebeee%2Fservicecontainer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/faebeee","download_url":"https://codeload.github.com/faebeee/servicecontainer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faebeee%2Fservicecontainer/sbom","scorecard":{"id":391302,"data":{"date":"2025-08-11","repo":{"name":"github.com/faebeee/servicecontainer","commit":"4f66487b95b2e57804177f6d5289188a452d8885"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.3,"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":"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":"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":"Code-Review","score":0,"reason":"Found 0/30 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":"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":"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":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"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":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"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":"Vulnerabilities","score":0,"reason":"23 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-h452-7996-h45h","Warn: Project is vulnerable to: GHSA-qrmc-fj45-qfc2","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","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-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-xf5p-87ch-gxw2","Warn: Project is vulnerable to: GHSA-5v2h-r2cx-5xgj","Warn: Project is vulnerable to: GHSA-rrrm-qjm4-v8hf","Warn: Project is vulnerable to: GHSA-wrvr-8mpx-r7pp","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-gqgv-6jq5-jjj9","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-8225-6cvr-8pqp","Warn: Project is vulnerable to: GHSA-mxhp-79qh-mcx6","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-18T17:53:00.596Z","repository_id":65494599,"created_at":"2025-08-18T17:53:00.596Z","updated_at":"2025-08-18T17:53:00.596Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32307011,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T17:23:19.671Z","status":"ssl_error","status_checked_at":"2026-04-26T17:23:19.195Z","response_time":129,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":[],"created_at":"2024-11-19T22:26:11.132Z","updated_at":"2026-04-26T17:32:01.468Z","avatar_url":"https://github.com/faebeee.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ServiceContainer\n\n![Build](https://circleci.com/gh/faebeee/servicecontainer/tree/master.svg?style=svg\u0026circle-token=50472bb3d7dbbb77fd1138181c19d6ed84d87dfd)\n\n`servicecontainer` is a zero dependency dependency injection for nodejs applications. \n\n# Install \nInstall the module using `npm`\n\n  `npm i servicecontainer --save`\n\n# Example\n\nCheckout the working example on `/example`\n\n- Basic Express example [Repo](https://github.com/faebeee/servicecontainer-example-express)\n\n# Setup\n\n## Create the service configuration file\nAll the service definitions are configured in a `json` file. Therefore we create \na `/config` folder in your application (It doesn't have to be in the app root since the\nfile reference is relative to the config file).\n\nThe config file looks something like this\n    \n    {  \n      \"parameters\" : {\n        \"name\" : \"foo bar\"\n      }\n      \"services\": {\n        \"helloService\": {\n          \"file\": \"../Services/Hello.service.js\",\n          \"arguments\" : [\"%name%\"]\n        }\n      }\n    }\n    \nThe config file has 3 main keys `parameters`, `services` and `imports`\n\n- `parameters` Will contain configurations for services (these will be parameters like \nportnumber and other config objects). These might be different depending on the environment\n\n- `services` Here all available services are configured. The keys have to be unique since that\nis the key you pass to retrieve the service.\n\n- `imports` here you can import other configurations files. This way you can have a more granular configuration and\nit makes it easier to have different parameters per environment and not have to write duplicated service configuration \n\n## Create a container and load the configuration\nNow that we have our configuration we are ready to create a container. Therefore we have to load the `servicecontainer` code.\nThats done by\n\n    const ServiceContainer = require('servicecontainer');\n    \nNext we create a new container instance by calling `create` with the configfile as parameter on `ServiceContainer`\n\n    let container = ServiceContainer.create(__dirname+'/config/service.json');\n\nThis normaly goes where your application boots/starts. Something like `/index.js` but\nit's not mandatory.\n\n## Use service\nNow that we have everything up and running, we can access the configured service.\nThat is done by calling `get` on the container and passing the service key from the configuration file.\n\n    container.get('helloService').myFancyMethod();\n\n\n# Create a service\nTo create a service we have two steps to do. First create your class.\n\nExample: HelloService.js\n\n    module.exports = class HelloService {\n        constructor(name){\n            this.name = name;\n        }\n        \n        myMethod1(){\n            ...\n        }\n\n        myMethod2(){\n            ...\n        }\n    }\n\nYou see it's very simple. Just a class which required a parameter called `name`. \nThat parameter will be passed by the `servicecontaine` module since it's configured\nin the config file \n    \n    ...\n    \"arguments\" : [\"%name%\"]\n    ...\n\nNow that we have created out class, we configure it in the config file and we are done.\n(Look above)\n\n# Configuration\nAt the beginning the configuration can be a bit tricky. But I got your back!\nAs mentioned above the configuration file exists of three parts. The `imports`,\n`parameters` and the `services`.\n\n## `imports`\n`imports` has to be an array. Here you can reference other configuration files. The \npath to those files is relative to the current one. The `import` files will be \nloaded prior to the current file. So if you have a parameter `name` in one of the imported\nfiles and tha same parameter in your current file, the current file overwrites the value.\n\nTo create some environment dependent config checkout the `example/environment` folder\n\n## `parameters`\nParameters is a key value object. It's very simple\n\n    {\n        \"parameters\" : {\n            \"name\" : \"foo bar\",\n            \"port\" : 8000\n        }\n    }\n\n## `services`\nThe service configuration is very straight foreward. The object has to have a unique key.\nThis key is later used to get access to that class/service.\nThe config object of that service has some keys you have to set and some are optional.\n\n|key|value|type|default|\n|---|---|---|---|\n|file|Relative path to the class file|required||\n|arguments|Array of parameters that are passed to the constructor when the service is created|required||\n|tags|Array of strings. You can get an array of services with the same tag|optional|`[]`|\n|isObject|Define if the service/class has to be instanciated with `new` when getting it |optional|`false`|\n\n### `arguments`\nYou can pass three different types of parameters. A normal string, a reference to a `parameter` or an other `service`.\n\nPass a string\n\n    \"arguments\" : [\"hello\"]\n\nReference a parameter. Parameter key is wrapped with `%`\n\n    \"arguments\" : [\"%hello%\"]\n\nReference another servcie. Prefix the service key/name with a `@`\n    \n    \"arguments\" : [\"@helloService\"]\n\n### `tags`\nYou can define an array of tags. You can access multiple services with tha same tags later.\nThat might be good when you have different eventlisteners, that have to be started \non application start. You can call `getServicesByTag` on the `container` object and pass\nthe tag you want and you'll receive an array of services.\n\n### `isObject`\nYou also have the possibility to add object as services and not classes.\nWhen `isObject` is set to `true` then the `service` will not bi instanciated with `new`.\nThis gives you the ability to pass an object as a service.\n\n# Use a service\nAfter you created the config and `service` file, you can access the service and call it's methods. In addition the `container` created with `ServiceContainer.create` is cached in\nthe module. This gives you the ability to load the `servicecontainer` module everywhere in your code. Then you can call `.get` on the module and you'll get the current\ncontainer instance.\n    \n# API\n## Module\n### `.create(configFilePath:String) : Container`\nCreate a new container instance. \n\n### `.get() : Container`\nGet the created container\n\n### `.destroy()`\nDestroy the currently active container\n\n## Container\n### `.getParameter(name:String) : any`\nGet a parameter by it's name\n\n### `.getServicesByTag(tag:String) : Array`\nGet multiple services by the same tag\n\n### `.get(name:String) : any`\nGet service by it's name\n\n# Complete API Doc\n[API Doc](https://faebeee.github.io/servicecontainer/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaebeee%2Fservicecontainer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffaebeee%2Fservicecontainer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaebeee%2Fservicecontainer/lists"}