{"id":20595271,"url":"https://github.com/myty/jimmy","last_synced_at":"2025-11-17T15:07:18.982Z","repository":{"id":43089576,"uuid":"451717024","full_name":"myty/jimmy","owner":"myty","description":"This is a simple library for using the mediator pattern in your typescript and deno projects. While not entirely a true port, the MediatR library for .NET is a direct influence.","archived":false,"fork":false,"pushed_at":"2024-09-15T19:41:44.000Z","size":96,"stargazers_count":6,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-19T02:50:38.172Z","etag":null,"topics":["deno","hacktoberfest","mediator-pattern","mediatr","typescript"],"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/myty.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2022-01-25T03:08:42.000Z","updated_at":"2024-08-30T22:28:05.000Z","dependencies_parsed_at":"2024-09-15T20:05:19.613Z","dependency_job_id":null,"html_url":"https://github.com/myty/jimmy","commit_stats":{"total_commits":28,"total_committers":2,"mean_commits":14.0,"dds":0.3571428571428571,"last_synced_commit":"82537009f2107d84f1e584b51db455ac4eb43613"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/myty/jimmy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myty%2Fjimmy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myty%2Fjimmy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myty%2Fjimmy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myty%2Fjimmy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/myty","download_url":"https://codeload.github.com/myty/jimmy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myty%2Fjimmy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284902877,"owners_count":27081963,"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","status":"online","status_checked_at":"2025-11-17T02:00:06.431Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["deno","hacktoberfest","mediator-pattern","mediatr","typescript"],"created_at":"2024-11-16T08:12:33.809Z","updated_at":"2025-11-17T15:07:18.962Z","avatar_url":"https://github.com/myty.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jimmy\n\n[![JSR](https://jsr.io/badges/@myty/jimmy)](https://jsr.io/@myty/jimmy)\n[![npm version](https://badge.fury.io/js/@myty%2Fjimmy.svg)](https://badge.fury.io/js/@myty%2Fjimmy)\n\nThis is a simple library for using the mediator pattern in your typescript and deno projects. While not entirely a true port, the MediatR library for .NET is a direct influence.\n\n## Why Jimmy?\n\n1. Former US President Jimmy Carter was known for his ability at being a great\n   mediator.\n2. The .NET Core library [MediatR](https://github.com/jbogard/MediatR) was\n   written by Jimmy Bogard.\n3. Coicdence? I think not.\n\n## Installation\n\n### Node.js\n\n```bash\n# npm\nnpm install --save @myty/jimmy\nnpx jsr add @myty/jimmy\n```\n\n### Deno\n\n```bash\nimport { Mediator, Request, Notification } from \"jsr:@myty/jimmy\";\n```\n\n## Usage\n\n```ts\nconst mediator = new Mediator();\n\nclass TestRequest extends Request\u003cPromise\u003cstring\u003e\u003e {\n  constructor(public name: string) {\n    super();\n  }\n}\n\nmediator.handle(\n  TestRequest,\n  (request) =\u003e Promise.resolve(`Hello, ${request.name}!`),\n);\n\nconst response = await mediator.send(new TestRequest(\"Jimmy\"));\n\nconsole.log(response); // \"Hello, Jimmy!\"\n```\n\n## Progress\n\nJimmy is inspired by the [MediatR](https://github.com/jbogard/MediatR) project,\nso here's what's been implemented:\n\n- [x] Request/Response messages\n- [x] Notification messages\n- [x] Publish Strategies (Notifications)\n\n## Basics\n\nJust like MediatR, Jimmy has two kinds of messages it dispatches:\n\n- Request/response messages, dispatched to a single handler\n- Notification messages, dispatched to multiple handlers\n\n### Request/Response\n\nThe request/response interface handles both command and query scenarios. First,\ncreate a message:\n\n```ts\nclass Ping extends Request\u003cPromise\u003cstring\u003e\u003e {}\n```\n\nNext, register a handler:\n\n```ts\nmediator.handle(Ping, (request) =\u003e Promise.resolve(\"Pong\"));\n```\n\nFinally, send a message through the mediator:\n\n```ts\nconst response = await mediator.send(new Ping());\nconsole.log(response); // \"Pong\"\n```\n\nIn the case your message does not require a response, use\n`Request\u003cPromise\u003cvoid\u003e\u003e` as your base class :\n\n```ts\nclass OneWay extends Request\u003cPromise\u003cvoid\u003e\u003e {}\nmediator.handle(OneWay, () =\u003e {\n  // Twiddle thumbs\n  Promise.resolve();\n});\n```\n\nOr if the request is completely synchronous, inherit from the base `Request`\nclass without any generic parameters. `void` is the default return type.\n\n```ts\nclass Ping extends Request {}\nmediator.handle(Ping, () =\u003e \"Pong\");\n```\n\n### Notifications\n\nFor notifications, first create your notification message:\n\n```ts\nclass Ping extends Notification {}\n```\n\nNext, register zero or more handlers for your notification:\n\n```ts\nmediator.handle(Ping, (notification) =\u003e {\n   console.log(\"Pong 1\");\n   return Promsie.resolve();\n}\n\nmediator.handle(Ping, (notification) =\u003e {\n   console.log(\"Pong 2\");\n   return Promsie.resolve();\n}\n```\n\nFinally, publish your message via the mediator:\n\n```ts\nawait mediator.publish(new Ping());\n```\n\n#### Publish Strategies\n\nThe default implementation of Publish loops through the notification handlers\nand awaits each one. This ensures each handler is run after one another.\n\nDepending on your use-case for publishing notifications, you might need a\ndifferent strategy for handling the notifications. Maybe you want to publish all\nnotifications in parallel, or wrap each notification handler with your own\nexception handling logic.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyty%2Fjimmy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmyty%2Fjimmy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyty%2Fjimmy/lists"}