{"id":20077558,"url":"https://github.com/digitaledgeit/service-oracle","last_synced_at":"2026-05-12T18:12:42.882Z","repository":{"id":26226912,"uuid":"29673578","full_name":"digitaledgeit/service-oracle","owner":"digitaledgeit","description":"A service locator.","archived":false,"fork":false,"pushed_at":"2015-10-11T00:09:56.000Z","size":196,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-19T01:34:58.626Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/digitaledgeit.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":"2015-01-22T10:38:04.000Z","updated_at":"2015-10-10T21:39:28.000Z","dependencies_parsed_at":"2022-07-24T10:30:04.471Z","dependency_job_id":null,"html_url":"https://github.com/digitaledgeit/service-oracle","commit_stats":null,"previous_names":["iso-js/locator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaledgeit%2Fservice-oracle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaledgeit%2Fservice-oracle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaledgeit%2Fservice-oracle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaledgeit%2Fservice-oracle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digitaledgeit","download_url":"https://codeload.github.com/digitaledgeit/service-oracle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241416489,"owners_count":19959595,"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":[],"created_at":"2024-11-13T15:08:56.550Z","updated_at":"2026-05-12T18:12:37.860Z","avatar_url":"https://github.com/digitaledgeit.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# service-oracle\n\n[![Build Status](https://travis-ci.org/digitaledgeit/service-oracle.svg?branch=master)](https://travis-ci.org/digitaledgeit/service-oracle)\n[![Coverage Status](https://coveralls.io/repos/digitaledgeit/service-oracle/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/digitaledgeit/service-oracle?branch=master)\n\nA service locator for NodeJS and the browser.\n\nThe all-knowing Oracle knows how to construct your services!\n\n## Installation\n\n    npm install --save service-oracle\n    \n## Usage\n    \n    var locator = require('service-oracle');\n    \n    //setup your services\n    var services = locator()\n    \t.instance('Config', require('./config.json'))\n    \t.factory('Database', function(locator) {\n    \t\tvar config    = locator.get('Config');\n    \t\tvar database  = new Database(config.db);\n    \t\treturn database;\n    \t})\n    \t.factory('Users', function(locator) {\n    \t\tvar database  = locator.get('Database');\n    \t\tvar users     = new Users(database);\n    \t\treturn users;\n    \t})\n    \t.factory('Posts', function(locator) {\n    \t\tvar database  = locator.get('Database');\n    \t\tvar posts     = new Posts(database);\n    \t\treturn posts;\n    \t})\n    \t.factory('BlogService', function(locator) {\n    \t\tvar users     = locator.get('Users');\n    \t\tvar posts     = locator.get('Posts');\n    \t\tvar service   = new BlogService(users, posts);\n    \t\treturn service;\n    \t})\n    ;\n    \n    //somewhere else e.g. in your express routes\n    var blog = services.get('BlogService');\n\n## API\n\n### Methods\n\n#### new ServiceOracle()\n\nCreate a new service locator.\n\n#### .has(name : string) : boolean\n\nCheck whether a service can be located.\n\n#### .new(name : string) : *\n\nCreate a new instance of a service.\n\n**Note**: Cannot create a new instance of a service registered with the `.instance()` method.\n\n#### .get(name : string) : *\n\nGet a shared instance of a service.\n\n#### .instance(name : string, value : *) : ServiceOracle\n\nRegister a shared instance of a service.\n\n#### .factory(name : string, value : string|function : ServiceOracle\n\nRegister a function or module path as a factory for creating services.\n\n#### .locator(locator : ServiceOracle) : ServiceOracle\n\nRegister another locator to proxy service location to.\n\n## Changelog\n\nv1.0.0\n\n- changed `.set(name, instance)` to `.instance(name, instance)`\n- added missing tests\n- updated documentation\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2015 James Newell","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitaledgeit%2Fservice-oracle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitaledgeit%2Fservice-oracle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitaledgeit%2Fservice-oracle/lists"}