{"_id":"@brainhubeu/sqrs","_rev":"18-3ecee57c28bac5255bc53729f309856a","name":"@brainhubeu/sqrs","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.3":{"name":"@brainhubeu/sqrs","version":"1.0.3","keywords":["cqrs","cqs","ddd","command","query","repository","segregation","domain","driven","event"],"author":{"url":"https://github.com/rkostrzewski","name":"Rafał Kostrzewski"},"license":"MIT","_id":"@brainhubeu/sqrs@1.0.3","maintainers":[{"name":"rkostrzewski","email":"poczta.raf.kos@gmail.com"},{"name":"kkoscielniak","email":"krystiankoscielniak@gmail.com"},{"name":"brainhubeu-ci","email":"dev@brainhub.pl"},{"name":"szymon.morawski","email":"szymon.morawski@brainhub.pl"},{"name":"szulcd2","email":"szulcd2@gmail.com"},{"name":"piotr-s-brainhub","email":"piotr.sroczkowski@brainhub.pl"},{"name":"dyoda","email":"lukasz.pluszczewski@gmail.com"},{"name":"drymek","email":"marcin@dryka.pl"},{"name":"brainhub-adam","email":"adam@brainhub.pl"}],"homepage":"https://github.com/brainhubeu/sqrs#readme","bugs":{"url":"https://github.com/brainhubeu/sqrs/issues"},"dist":{"shasum":"d236719c52b5fd8780414325a02fc36e67a5775f","tarball":"https://registry.npmjs.org/@brainhubeu/sqrs/-/sqrs-1.0.3.tgz","fileCount":54,"integrity":"sha512-oRSpiY5PZBPoLB08EwHBrFE2z1/cZW1Tr45SfjocvTdIhaHzFeNKXA9YL49Isn9SvyMIEGkTtCgo8WFFvapeWg==","signatures":[{"sig":"MEUCICENNs5PQ2FJY54op2ljfEFTXRC5GWQE/uo/zX6cDPzGAiEAwcd55r2sOZZWzjAJ8fjpZfaha471i76r6gOzFvJhSL8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36739,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeeH1XCRA9TVsSAnZWagAAE9wP/icHHTftO6/+BCCkGZRA\n+3ucleQjIjn0/tAssl+M6Gth0S3oXFzE7MuswpmjEgt0/Lg7Kc+Gb53Hp73N\nRg8e2Nod69814ldxV0/74YMkE1rLiMTVz7BauOGsU1QgiRxRqK9Kf8gzcymD\nMi3y/19Nyz9eekpiI9mYSk1SkmII5OGnByEa1pVqu08/zHhdtVOarOW04V0M\nXxfZxEu/TGt6WkaVFdVLOgwogLmxOVnYWGsy535B74rSVxmBrKOjJuEik1EF\nQqs+ga3QsWHDe0i/UFFrQkdTFpi8SqN5YBRiXCOLgmq0aaHJ3LhEtM7a+nis\nrOLEWZtVDAfOy6Ucw0nKQ1H2jJBd5gH3nWa5VeIyIp/Vd/UMWOe88BUC1X+M\n4ND/JsfCShzrZugQvxXlFoZss+WLRROpb32lcoVluIWeXjPHo/U7np8xDNvb\nS0DU5mcc7Qh+TNVdPrE/sZUt0LpIxGzWPX4jGWL2p/xA/n926JeDx2BfRgaa\ncWETIDk3nYKZU7ET4XDS7FI/3tPLMEt9YlfTmGuERL80k0DRAwkFdqDcf7H1\npSSekfIkEhI+ShGlE+WkPy7xzHqW90ixn1s+RqUlIwbd/Qio5Q7EeiCYSBbf\nU/3zI968lC4047cz2CZzPiboZBZfc7gifhicPWBVfVT8hY4J8Iz6H+mpUF5N\noELi\r\n=YP1S\r\n-----END PGP SIGNATURE-----\r\n"},"jest":{"preset":"ts-jest"},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"703186670f7b5fd0fb7549e6566c1709119e1084","scripts":{"doc":"typedoc --options typedoc.json --out ../../docs/api","lint":"tslint --project ./tsconfig.json 'src/**/*'","test":"jest","build":"tsc --outDir dist","predoc":"rimraf ../../docs/api","prebuild":"rimraf dist"},"_npmUser":{"name":"rkostrzewski","email":"poczta.raf.kos@gmail.com"},"repository":{"url":"git+ssh://git@github.com/brainhubeu/sqrs.git","type":"git"},"_npmVersion":"lerna/3.20.2/node@v10.16.0+x64 (darwin)","description":"CQRS framework for JavaScript/TypeScript servers","directories":{},"_nodeVersion":"10.16.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^25.1.0","rimraf":"^2.6.2","tslint":"^5.11.0","ts-jest":"^25.2.1","typedoc":"^0.17.3","@babel/cli":"^7.2.3","typescript":"^3.8.3","@types/jest":"^23.3.13","typedoc-plugin-markdown":"^2.2.17","typedoc-plugin-external-module-name":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sqrs_1.0.3_1584954711506_0.8903850010874614","host":"s3://npm-registry-packages"}}},"time":{"created":"2020-03-23T09:11:51.272Z","modified":"2024-10-25T13:04:48.991Z","1.0.3":"2020-03-23T09:11:51.610Z"},"bugs":{"url":"https://github.com/brainhubeu/sqrs/issues"},"author":{"url":"https://github.com/rkostrzewski","name":"Rafał Kostrzewski"},"license":"MIT","homepage":"https://github.com/brainhubeu/sqrs#readme","keywords":["cqrs","cqs","ddd","command","query","repository","segregation","domain","driven","event"],"repository":{"url":"git+ssh://git@github.com/brainhubeu/sqrs.git","type":"git"},"description":"CQRS framework for JavaScript/TypeScript servers","maintainers":[{"email":"angjeziorska@gmail.com","name":"angjez"},{"email":"mateusz.jarzebowski.bownik@gmail.com","name":"matt-jb"},{"email":"filip.kublin@brainhub.pl","name":"fkublin"},{"email":"cypherq@gmail.com","name":"benedyktdryl"},{"email":"dariusz.luber@gmail.com","name":"dluber"},{"email":"devops@brainhub.pl","name":"brainhubeu-devops"},{"email":"anna.lach@brainhub.pl","name":"annalach"},{"email":"szymon.morawski@brainhub.pl","name":"szymon.morawski"},{"email":"lukasz.pluszczewski@gmail.com","name":"dyoda"},{"email":"dev@brainhub.pl","name":"brainhubeu-ci"},{"email":"robert_hebel@icloud.com","name":"roberthebel"}],"readme":"# sqrs\n\nSQRS is a JavaScript library for implementing CQRS pattern.\n\nBest used with TypeScript as it exposes interfaces for Commands, CommandHandlers, Queries, QueryHandlers and more.\n\nWhen paired with a dependency injection framework it provides a fully-fledged inversion of control experience in JavaScript.\n\n# Installation\n\nTo install sqrs run\n\n`npm install sqrs`\n\nthe packages comes with it's own TypeScript types.\n\nES2015 execution environment is required. For NodeJS that means at least Node 8 LTS.\n\n# Getting started\n\n## Introduction to CQRS\n\nIn short, CQRS is a pattern that differentiates between read operations and write operations. Write operations are achieved via commands that represent intent to change the system's state, and read operations are achieved via queries that read the system's state. The distinction between the to comes from the principle that asking a question shouldn't change the response.\n\nYou can read more about CQRS here:\n\n- https://www.martinfowler.com/bliki/CQRS.html\n- http://www.cqrs.nu\n\n## Using the library\n\n[See the longer guide for getting started](/docs/usage.md)\n\n### Short version\n\nWriting commands (note you don't have to use classes, you can also use object factories):\n```ts\nimport { Command } from '@brainhubeu/sqrs';\n\nexport class AddNoteCommand implements Command {\n  public type = 'add-note';\n  public text: string;\n\n  constructor (text: string) {\n    this.text = text;\n  }\n}\n```\n\nWriting command handlers:\n```ts\nimport { CommandHandler } from '@brainhubeu/sqrs';\n\nclass AddNoteCommandHandler implements CommandHandler {\n  public handle (command: AddNoteCommand) {\n    // do something with the command\n  }\n}\n```\n\nWriting queries:\n```ts\nimport { Query } from '@brainhubeu/sqrs';\n\nexport class GetNotesQuery implements Query<string, Note[]> {\n  public queryName = 'GetNotes';\n}\n```\n\nWriting query handlers:\n```ts\nimport { QueryHandler } from '@brainhubeu/sqrs';\n\nexport class GetNotesQueryHandler implements QueryHandler<GetNotesQuery> {\n  execute (query: GetNotesQuery): Promise<Note[]> {\n    // get notes from somewhere\n  }\n}\n```\n\nFinal usage:\n```ts\nimport { DefaultCommandBus, CommandBus, DefaultQueryExecutor, QueryExecutor } from '@brainhubeu/sqrs';\n\nconst commandBus: CommandBus = new DefaultCommandBus(\n  // created somewhere else\n  commandHandlerProvider,\n  commandValidatorProvider\n);\nconst queryExecutor: QueryExecutor = new DefaultQueryExecutor(\n  // created somewhere else\n  queryHandlerProvider\n);\n\nconst addNoteCommand = new AddNoteCommand('hello');\nawait commandBus.dispatch(addNoteCommand);\n\nconst getNotesQuery = new GetNotesQuery();\nconst notes = await queryExecutor.execute(getNotesQuery);\n```\n\n# API reference\n\nAPI reference generated from JSDoc comment can be found [here](/docs/api)\n\n# Example project\n\nExample project created using this library can be found [here](/packages/example-project) \n\n","readmeFilename":"README.md"}