{"id":25837236,"url":"https://github.com/devtin/duckfficer-method-di","last_synced_at":"2026-05-13T04:37:52.347Z","repository":{"id":57216970,"uuid":"336839076","full_name":"devtin/duckfficer-method-di","owner":"devtin","description":"loads duckfficer-method entities from a path to provide a pleasure-di container","archived":false,"fork":false,"pushed_at":"2021-07-15T14:21:24.000Z","size":190,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-17T16:42:58.921Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/devtin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2021-02-07T16:54:33.000Z","updated_at":"2021-07-15T14:21:29.000Z","dependencies_parsed_at":"2022-08-28T21:40:17.398Z","dependency_job_id":null,"html_url":"https://github.com/devtin/duckfficer-method-di","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtin%2Fduckfficer-method-di","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtin%2Fduckfficer-method-di/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtin%2Fduckfficer-method-di/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtin%2Fduckfficer-method-di/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devtin","download_url":"https://codeload.github.com/devtin/duckfficer-method-di/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241309091,"owners_count":19941726,"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":"2025-03-01T02:48:00.725Z","updated_at":"2026-05-13T04:37:52.309Z","avatar_url":"https://github.com/devtin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv\u003e\u003ch1\u003educkfficer-method-di\u003c/h1\u003e\u003c/div\u003e\n\n\u003cp\u003e\n    \u003ca href=\"https://www.npmjs.com/package/duckfficer-method-di\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/duckfficer-method-di.svg\" alt=\"Version\"\u003e\u003c/a\u003e\n\u003ca href=\"http://opensource.org/licenses\" target=\"_blank\"\u003e\u003cimg src=\"http://img.shields.io/badge/License-MIT-brightgreen.svg\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp\u003e\n    loads duckfficer-method entities from a path to provide a pleasure-di container\n\u003c/p\u003e\n\n## Installation\n\n```sh\n$ npm i duckfficer-method-di --save\n# or\n$ yarn add duckfficer-method-di\n```\n\n## Features\n\n- [builds an object appending all method found in given paths](#builds-an-object-appending-all-method-found-in-given-paths)\n- [validates input](#validates-input)\n- [validates output](#validates-output)\n- [emits events](#emits-events)\n\n\n\u003ca name=\"builds-an-object-appending-all-method-found-in-given-paths\"\u003e\u003c/a\u003e\n\n## builds an object appending all method found in given paths\n\n\n```js\nconst container = duckfficerMethodDi({\n  Gateway: 'gateways',\n  Service: 'services'\n}, {\n  baseDir: path.join(__dirname, './__tests__/fixtures')\n})\n\nconst { OrderService } = container\nt.deepEqual(await OrderService.payment({\n  id: '123',\n  amount: 99\n}), {\n  id: '123',\n  result: 'paying 99$'\n})\n```\n\n\u003ca name=\"validates-input\"\u003e\u003c/a\u003e\n\n## validates input\n\n\n```js\nconst container = duckfficerMethodDi({\n  Gateway: 'gateways',\n  Service: 'services'\n}, {\n  baseDir: path.join(__dirname, './__tests__/fixtures')\n})\n\nconst { PayPalGateway } = container\nconst { originalError } = await t.throwsAsync(() =\u003e PayPalGateway.pay('100'), {\n  message: 'Invalid input'\n})\nt.like(originalError, {\n  message: 'Invalid number'\n})\n```\n\n\u003ca name=\"validates-output\"\u003e\u003c/a\u003e\n\n## validates output\n\n\n```js\nconst container = duckfficerMethodDi({\n  Gateway: 'gateways',\n  Service: 'services'\n}, {\n  baseDir: path.join(__dirname, './__tests__/fixtures')\n})\n\nconst { PayPalGateway } = container\n\nconst { originalError } = await t.throwsAsync(() =\u003e PayPalGateway.pay(0), {\n  message: 'Invalid output'\n})\n\nt.like(originalError, {\n  message: 'Invalid string'\n})\n```\n\n\u003ca name=\"emits-events\"\u003e\u003c/a\u003e\n\n## emits events\n\n\n```js\nconst container = duckfficerMethodDi({\n  Gateway: 'gateways',\n  Service: 'services'\n}, {\n  baseDir: path.join(__dirname, './__tests__/fixtures')\n})\n\nconst { PayPalGateway } = container\n\nPayPalGateway.on('Paid', (payload) =\u003e {\n  t.log(payload)\n  t.pass()\n})\n\nreturn PayPalGateway.pay(100)\n```\n\n\n\u003cbr\u003e\u003ca name=\"duckfficerMethodDi\"\u003e\u003c/a\u003e\n\n### duckfficerMethodDi(pathResolvers, [baseDir], [methodsPath]) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n\n| Param | Type | Default |\n| --- | --- | --- |\n| pathResolvers | \u003ccode\u003eObject\u003c/code\u003e |  | \n| [baseDir] | \u003ccode\u003eString\u003c/code\u003e | \u003ccode\u003eprocess.cwd()\u003c/code\u003e | \n| [methodsPath] | \u003ccode\u003eString\u003c/code\u003e | \u003ccode\u003emethods\u003c/code\u003e | \n\n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - container  \n\n* * *\n\n### License\n\n[MIT](https://opensource.org/licenses/MIT)\n\n\u0026copy; 2020-present Martin Rafael Gonzalez \u003ctin@devtin.io\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevtin%2Fduckfficer-method-di","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevtin%2Fduckfficer-method-di","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevtin%2Fduckfficer-method-di/lists"}