{"id":24973385,"url":"https://github.com/thenativeweb/node-evented-command","last_synced_at":"2025-04-11T08:44:13.331Z","repository":{"id":2360938,"uuid":"3324576","full_name":"thenativeweb/node-evented-command","owner":"thenativeweb","description":"provides simple command/event handling for evented systems like cqrs","archived":false,"fork":false,"pushed_at":"2020-09-01T09:02:42.000Z","size":46,"stargazers_count":15,"open_issues_count":0,"forks_count":4,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-03T01:34:06.292Z","etag":null,"topics":["command","cqrs","event","javascript","observer"],"latest_commit_sha":null,"homepage":"http://cqrs.js.org/pages/eventedcommand.html","language":"JavaScript","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/thenativeweb.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}},"created_at":"2012-02-01T12:23:20.000Z","updated_at":"2023-02-07T12:52:24.000Z","dependencies_parsed_at":"2022-08-17T21:25:59.699Z","dependency_job_id":null,"html_url":"https://github.com/thenativeweb/node-evented-command","commit_stats":null,"previous_names":["adrai/node-evented-command","adrai/nodeeventedcommand"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thenativeweb%2Fnode-evented-command","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thenativeweb%2Fnode-evented-command/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thenativeweb%2Fnode-evented-command/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thenativeweb%2Fnode-evented-command/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thenativeweb","download_url":"https://codeload.github.com/thenativeweb/node-evented-command/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248362665,"owners_count":21091172,"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":["command","cqrs","event","javascript","observer"],"created_at":"2025-02-03T18:59:06.498Z","updated_at":"2025-04-11T08:44:13.309Z","avatar_url":"https://github.com/thenativeweb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ⚠️ IMPORTANT NEWS! 📰\n\nI’ve been dealing with CQRS, event-sourcing and DDD long enough now that I don’t need working with it anymore unfortunately, so at least for now this my formal farewell!\n\nI want to thank everyone who has contributed in one way or another.\nEspecially...\n\n- [Jan](https://github.com/jamuhl), who introduced me to this topic.\n- [Dimitar](https://github.com/nanov), one of the last bigger contributors and maintainer.\n- My last employer, who gave me the possibility to use all these CQRS modules in a big Cloud-System.\n- My family and friends, who very often came up short.\n\nFinally, I would like to thank [Golo Roden](https://github.com/goloroden), who was there very early at the beginning of my CQRS/ES/DDD journey and is now here again to take over these modules.\n\nGolo Roden is the founder, CTO and managing director of [the native web](https://www.thenativeweb.io/), a company specializing in native web technologies. Among other things, he also teaches CQRS/ES/DDD etc. and based on his vast knowledge, he brought wolkenkit to life.\n[wolkenkit](https://wolkenkit.io) is a CQRS and event-sourcing framework based on Node.js. It empowers you to build and run scalable distributed web and cloud services that process and store streams of domain events.\n\nWith this step, I can focus more on [i18next](https://www.i18next.com), [locize](https://locize.com) and [localistars](https://localistars.com). I'm happy about that. 😊\n\nSo, there is no end, but the start of a new phase for my CQRS modules 😉\n\nI wish you all good luck on your journey.\n\nWho knows, maybe we'll meet again in a github issue or PR at [i18next](https://github.com/i18next/i18next) 😉\n\n\n[Adriano Raiano](https://twitter.com/adrirai)\n\n---\n\n# Introduction\n\n[![travis](https://img.shields.io/travis/adrai/node-evented-command.svg)](https://travis-ci.org/adrai/node-evented-command) [![npm](https://img.shields.io/npm/v/evented-command.svg)](https://npmjs.org/package/evented-command)\n\nProject goal is to provide a simple command/event handling for evented systems like cqrs.\n\n# Installation\n\n\tnpm install evented-command\n\n# Usage\n\n\tvar evtCmd = require('evented-command')();\n\n## Define the command structure [optional]\nThe values describes the path to that property in the command message.\n\n\tevtCmd.defineCommand({\n\t  id: 'id',                       // optional\n\t  name: 'name',                   // optional\n\t  context: 'context.name',        // optional\n\t  aggregate: 'aggregate.name',    // optional\n\t  aggregateId: 'aggregate.id'     // optional\n\t});\n\n## Define the event structure [optional]\nThe values describes the path to that property in the event message.\n\n\tevtCmd.defineEvent({\n\t  correlationId: 'correlationId', // optional\n\t  id: 'id',                       // optional\n\t  name: 'name',                   // optional\n\t  context: 'context.name',        // optional\n\t  aggregate: 'aggregate.name',    // optional\n\t  aggregateId: 'aggregate.id'     // optional\n\t});\n\n## Define the id generator function [optional]\n### you can define a synchronous function\n\n\tevtCmd.idGenerator(function() {\n\t  var id = require('uuid').v4().toString();\n\t  return id;\n\t});\n\n### or you can define an asynchronous function\n\n\tevtCmd.idGenerator(function(callback) {\n\t  setTimeout(function() {\n\t    var id = require('uuid').v4().toString();\n\t    callback(null, id);\n\t  }, 50);\n\t});\n\n## Wire up commands and events\n\n\t// pass in events from your bus\n\tbus.on('event', function(data){\n\t  evtCmd.emit('event', data);\n\t});\n\n\t// pass commands to bus\n\tevtCmd.on('command', function(data) {\n\t  bus.emit('command', data);\n\t});\n\n## Send commands\n\n\tvar cmd = new Command({\n\t  // id: 'my onwn command id', // if you don't pass an id it will generate one, when emitting the command...\n\t  name: 'changePerson',\n\t  payload: {\n\t    name: 'my name'\n\t  },\n\t  aggregate: {\n\t    id: 8,\n\t    name: 'jack'\n\t  },\n\t  context: {\n\t    name: 'hr'\n\t  }\n\t});\n\n\t// emit it\n\tcmd.emit();\n\n\n\n\t// if you want to observe the command pass a callback\n\tcmd.emit(function(evt) {\n\n\t});\n\n\n\t// if you want to observe the command that generates any events pass an object like this:\n\tcmd.emit({\n\n\t  event1: function(evt) {\n\n\t  },\n\n\t  event2: function(evt) {\n\n\t  }\n\n\t});\n\n### Send commands with the speakable api\n\n\tevtCmd.send('changePerson')\n\t      .for('person') // aggregate name\n\t      .instance('8') // aggregate id\n\t      .in('hr')\t\t\t // context name\n\t      .with({\n\t        // id: 'my onwn command id', // if you don't pass an id it will generate one, when emitting the command...\n\t        revision: '12',\n\t        payload: {\n\t        \tname: 'jack'\n\t        }\n\t      })\n\t      .go(function(evt) {\n\t        console.log('speakable', evt);\n\t      });\n\n\tevtCmd.send('multi')\n\t      .for('aggregate')\n\t      .instance('instanceId')\n\t      .in('context')\n\t      .with({\n\t        revision: '43',\n\t        payload: 'data2'\n\t      })\n\t      .go({\n\t        event1: function(evt) {\n\t          console.log('speakable', evt);\n\t        },\n\t        event2: function(evt) {\n\t          console.log('speakable', evt);\n\t        }\n\t      });\n\n# License\n\nCopyright (c) 2016 Adriano Raiano\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthenativeweb%2Fnode-evented-command","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthenativeweb%2Fnode-evented-command","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthenativeweb%2Fnode-evented-command/lists"}