{"_id":"@camcima/nestjs-memory-microservices","_rev":"4-599eaacf9b4bf18f58012133da456b61","name":"@camcima/nestjs-memory-microservices","dist-tags":{"latest":"0.3.0"},"versions":{"0.1.2":{"name":"@camcima/nestjs-memory-microservices","version":"0.1.2","keywords":["nestjs","microservices","testing","in-memory","transport","custom-transport","event-pattern","message-pattern"],"author":{"url":"https://github.com/camcima","name":"camcima"},"license":"MIT","_id":"@camcima/nestjs-memory-microservices@0.1.2","maintainers":[{"name":"camcima","email":"camcima@hotmail.com"}],"homepage":"https://github.com/camcima/nestjs-memory-microservices","bugs":{"url":"https://github.com/camcima/nestjs-memory-microservices/issues"},"dist":{"shasum":"9b8d97793b001b905fdcbe926e0f90801bfa9cfe","tarball":"https://registry.npmjs.org/@camcima/nestjs-memory-microservices/-/nestjs-memory-microservices-0.1.2.tgz","fileCount":18,"integrity":"sha512-t7OYQ6Hft7DptZgmUP+mJH9ExiZhJT7LAZCS24KGJzFMcnbvkpReOyf69/yNJaEhu/3pGssyKLWrpI6RETF1eg==","signatures":[{"sig":"MEUCIQD+BthGTdDec4xgWT3nWSojztMD3QUgOL2N9Ju869jygQIgeY/ofX/HnLsVlIMs4MamgmZrCuP7Z8NLBMKiSA2ARFU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18070},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"19d2ae53cd0e94b5c24379917d5627da1e8fdaa4","scripts":{"lint":"tsc --noEmit","test":"jest","build":"tsc -p tsconfig.build.json","format":"prettier --write \"src/**/*.ts\" \"test/**/*.ts\"","release":"release-it","prebuild":"rm -rf dist","test:cov":"jest --coverage","test:watch":"jest --watch","format:check":"prettier --check \"src/**/*.ts\" \"test/**/*.ts\"","prepublishOnly":"npm run build"},"_npmUser":{"name":"camcima","email":"camcima@hotmail.com"},"repository":{"url":"git+https://github.com/camcima/nestjs-memory-microservices.git","type":"git"},"_npmVersion":"11.6.3","description":"In-memory NestJS microservice transport for testing — full pipeline, zero broker","directories":{},"_nodeVersion":"22.16.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","rxjs":"^7.8.0","ts-jest":"^29.1.0","prettier":"^3.2.0","release-it":"^19.0.0","typescript":"^5.4.0","@types/jest":"^29.5.0","@types/node":"^20.0.0","@nestjs/core":"^11.0.0","@nestjs/common":"^11.0.0","@nestjs/testing":"^11.0.0","class-validator":"^0.14.0","reflect-metadata":"^0.2.0","class-transformer":"^0.5.0","@nestjs/microservices":"^11.0.0","@nestjs/platform-express":"^11.0.0"},"peerDependencies":{"rxjs":"^7.0.0","@nestjs/core":"^10.0.0 || ^11.0.0","@nestjs/common":"^10.0.0 || ^11.0.0","reflect-metadata":"^0.1.13 || ^0.2.0","@nestjs/microservices":"^10.0.0 || ^11.0.0"},"_npmOperationalInternal":{"tmp":"tmp/nestjs-memory-microservices_0.1.2_1774739609070_0.25660635316571634","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@camcima/nestjs-memory-microservices","version":"0.2.0","keywords":["nestjs","microservices","testing","in-memory","transport","custom-transport","event-pattern","message-pattern"],"author":{"url":"https://github.com/camcima","name":"camcima"},"license":"MIT","_id":"@camcima/nestjs-memory-microservices@0.2.0","maintainers":[{"name":"camcima","email":"camcima@hotmail.com"}],"homepage":"https://github.com/camcima/nestjs-memory-microservices","bugs":{"url":"https://github.com/camcima/nestjs-memory-microservices/issues"},"dist":{"shasum":"ee1e8d19534388340cc88a2eeb424b1fc92f8e87","tarball":"https://registry.npmjs.org/@camcima/nestjs-memory-microservices/-/nestjs-memory-microservices-0.2.0.tgz","fileCount":19,"integrity":"sha512-u0Au5YkHacrRvUFD8La2LwYlutUtWAUdiYaOWXyY/jC9V5o49CxNluM3guFO4Rtmx4yu5B3HNleOazfc148Y1w==","signatures":[{"sig":"MEUCIA1B8PHjbqpkBm076EqCZMIac5W2JwaNpphJI2uCpZAuAiEA+ZYHbUses/7APXDiejRvlV8KhL5sQahS7uLWpYljwY4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":20610},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"797f2c6f3cf27a0c356c99fa0b75b9c001c26b7d","scripts":{"lint":"tsc --noEmit","test":"vitest run","build":"tsc -p tsconfig.build.json","format":"prettier --write \"src/**/*.ts\" \"test/**/*.ts\"","prepare":"lefthook install","release":"release-it","prebuild":"rm -rf dist","test:cov":"vitest run --coverage","test:watch":"vitest","format:check":"prettier --check \"src/**/*.ts\" \"test/**/*.ts\"","prepublishOnly":"npm run build","security:audit":"npm audit --omit=dev","security:secrets":"gitleaks detect --redact --no-banner"},"_npmUser":{"name":"camcima","email":"camcima@hotmail.com"},"repository":{"url":"git+https://github.com/camcima/nestjs-memory-microservices.git","type":"git"},"_npmVersion":"11.6.3","description":"In-memory NestJS microservice transport for testing — full pipeline, zero broker","directories":{},"_nodeVersion":"22.16.0","_hasShrinkwrap":false,"devDependencies":{"rxjs":"^7.8.0","vitest":"^3.2.4","lefthook":"^2.1.5","prettier":"^3.2.0","@swc/core":"^1.15.24","release-it":"^19.0.0","typescript":"^6.0.2","@types/node":"^25.5.2","@nestjs/core":"^11.0.0","unplugin-swc":"^1.5.9","@nestjs/common":"^11.0.0","@nestjs/testing":"^11.0.0","class-validator":"^0.15.1","reflect-metadata":"^0.2.0","class-transformer":"^0.5.0","@vitest/coverage-v8":"^3.2.4","@nestjs/microservices":"^11.0.0","@nestjs/platform-express":"^11.0.0"},"peerDependencies":{"rxjs":"^7.0.0","@nestjs/core":"^10.0.0 || ^11.0.0","@nestjs/common":"^10.0.0 || ^11.0.0","reflect-metadata":"^0.1.13 || ^0.2.0","@nestjs/microservices":"^10.0.0 || ^11.0.0"},"_npmOperationalInternal":{"tmp":"tmp/nestjs-memory-microservices_0.2.0_1775487413766_0.8215781484083511","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@camcima/nestjs-memory-microservices","version":"0.2.1","keywords":["nestjs","microservices","testing","in-memory","transport","custom-transport","event-pattern","message-pattern"],"author":{"url":"https://github.com/camcima","name":"camcima"},"license":"MIT","_id":"@camcima/nestjs-memory-microservices@0.2.1","maintainers":[{"name":"camcima","email":"camcima@hotmail.com"}],"homepage":"https://github.com/camcima/nestjs-memory-microservices","bugs":{"url":"https://github.com/camcima/nestjs-memory-microservices/issues"},"dist":{"shasum":"33a2d14a4d2b3cd0305da5fbdf547a3aa1cc0090","tarball":"https://registry.npmjs.org/@camcima/nestjs-memory-microservices/-/nestjs-memory-microservices-0.2.1.tgz","fileCount":19,"integrity":"sha512-VNaLIrzByPVHkv7z6O66yllAizyc83Lb0U0xT7Hrj00wbQagz4VtrioYcG+z94hOEF4nfHmUeyOr/e102VinjA==","signatures":[{"sig":"MEYCIQDxe3OaD67XWR4M8YpJKteB3JC80TnR6DAWLJ/3ot1MjQIhAJszqCNSCr+tNzBLjdNlpGXeajK8QT2/w6MGhgp5CLPl","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":20846},"main":"dist/index.js","pnpm":{"overrides":{"defu":">=6.1.5","vite":">=7.3.2 <8","lodash":">=4.18.0","undici":">=6.24.0","postcss":">=8.5.10","basic-ftp":">=5.3.0"}},"types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"5ada85e8da5ec6632560fbf16963cc0f6ce0d322","scripts":{"lint":"tsc --noEmit","test":"vitest run","build":"tsc -p tsconfig.build.json","format":"prettier --write \"src/**/*.ts\" \"test/**/*.ts\"","prepare":"lefthook install","release":"release-it","prebuild":"rm -rf dist","test:cov":"vitest run --coverage","test:watch":"vitest","format:check":"prettier --check \"src/**/*.ts\" \"test/**/*.ts\"","prepublishOnly":"pnpm run build","security:audit":"pnpm audit --prod","security:secrets":"gitleaks detect --redact --no-banner"},"_npmUser":{"name":"camcima","email":"camcima@hotmail.com"},"repository":{"url":"git+https://github.com/camcima/nestjs-memory-microservices.git","type":"git"},"_npmVersion":"10.9.7","description":"In-memory NestJS microservice transport for testing — full pipeline, zero broker","directories":{},"_nodeVersion":"22.22.2","_hasShrinkwrap":false,"packageManager":"pnpm@10.17.0","devDependencies":{"rxjs":"^7.8.2","vitest":"^4.1.7","lefthook":"^2.1.9","prettier":"^3.8.3","@swc/core":"^1.15.40","release-it":"^20.2.0","typescript":"^6.0.3","@types/node":"^25.9.1","@nestjs/core":"^11.1.24","unplugin-swc":"^1.5.9","@nestjs/common":"^11.1.24","@nestjs/testing":"^11.1.24","class-validator":"^0.15.1","reflect-metadata":"^0.2.2","class-transformer":"^0.5.1","@vitest/coverage-v8":"^4.1.7","@nestjs/microservices":"^11.1.24","@nestjs/platform-express":"^11.1.24"},"peerDependencies":{"rxjs":"^7.0.0","@nestjs/core":"^10.0.0 || ^11.0.0","@nestjs/common":"^10.0.0 || ^11.0.0","reflect-metadata":"^0.1.13 || ^0.2.0","@nestjs/microservices":"^10.0.0 || ^11.0.0"},"_npmOperationalInternal":{"tmp":"tmp/nestjs-memory-microservices_0.2.1_1780177320193_0.22104333969564594","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@camcima/nestjs-memory-microservices","version":"0.3.0","description":"In-memory NestJS microservice transport for testing — full pipeline, zero broker","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./package.json":"./package.json"},"sideEffects":false,"scripts":{"prebuild":"rm -rf dist","build":"tsc -p tsconfig.build.json","test":"vitest run","test:watch":"vitest","test:cov":"vitest run --coverage","lint":"tsc -p tsconfig.json --noEmit && tsc -p tsconfig.spec.json","format":"prettier --write \"src/**/*.ts\" \"test/**/*.ts\"","format:check":"prettier --check \"src/**/*.ts\" \"test/**/*.ts\"","release":"release-it","prepare":"lefthook install","prepublishOnly":"pnpm run build","security:audit":"pnpm audit --prod","security:secrets":"gitleaks detect --redact --no-banner"},"keywords":["nestjs","microservices","testing","in-memory","transport","custom-transport","event-pattern","message-pattern"],"author":{"name":"camcima","url":"https://github.com/camcima"},"repository":{"type":"git","url":"git+https://github.com/camcima/nestjs-memory-microservices.git"},"homepage":"https://github.com/camcima/nestjs-memory-microservices","bugs":{"url":"https://github.com/camcima/nestjs-memory-microservices/issues"},"license":"MIT","peerDependencies":{"@nestjs/common":"^10.0.0 || ^11.0.0","@nestjs/core":"^10.0.0 || ^11.0.0","@nestjs/microservices":"^10.0.0 || ^11.0.0","reflect-metadata":"^0.1.13 || ^0.2.0","rxjs":"^7.0.0"},"devDependencies":{"@nestjs/common":"^11.2.0","@nestjs/core":"^11.2.0","@nestjs/microservices":"^11.2.0","@nestjs/platform-express":"^11.2.0","@nestjs/testing":"^11.2.0","@release-it/conventional-changelog":"^12.0.0","@swc/core":"^1.15.47","@types/node":"^26.2.0","@vitest/coverage-v8":"^4.1.9","class-transformer":"^0.5.1","class-validator":"^0.15.1","lefthook":"^2.1.10","prettier":"^3.9.6","reflect-metadata":"^0.2.2","release-it":"^21.0.2","rxjs":"^7.8.2","typescript":"^7.0.2","unplugin-swc":"^1.5.11","vitest":"^4.1.9"},"pnpm":{"overrides":{"basic-ftp":">=5.3.0","defu":">=6.1.5","esbuild":">=0.28.1","lodash":">=4.18.0","multer":">=2.2.0","postcss":">=8.5.10","undici":">=8.5.0","vite":">=7.3.5 <8"}},"engines":{"node":">=20.19.0"},"packageManager":"pnpm@10.17.0","_id":"@camcima/nestjs-memory-microservices@0.3.0","gitHead":"faa25d7b1862d80a74b9c3fefb15a7014b67707a","_nodeVersion":"22.22.2","_npmVersion":"10.9.7","dist":{"integrity":"sha512-RbtRzUiGEmCI2HzmFqDG1TTchobhUzgpoS6lgIFpS9wXYkp/An9YgSLvZGj0BzTLTxxepW0zEa5+GVWXerU/xA==","shasum":"c7821d3623880cd4c21432c5753cfba6ae802284","tarball":"https://registry.npmjs.org/@camcima/nestjs-memory-microservices/-/nestjs-memory-microservices-0.3.0.tgz","fileCount":20,"unpackedSize":24175,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC2isr9kuIvF99pPpc1BXHxqVB6Ouio4uzHLIlZFTw+1AIgFg0m+lqNYAtg06BGOgtqGIXRFenHyyE3ArBXZszC72k="}]},"_npmUser":{"name":"camcima","email":"camcima@hotmail.com"},"directories":{},"maintainers":[{"name":"camcima","email":"camcima@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/nestjs-memory-microservices_0.3.0_1787147201812_0.056963475913337724"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-28T23:13:28.990Z","modified":"2026-08-19T13:46:42.285Z","0.1.2":"2026-03-28T23:13:29.239Z","0.2.0":"2026-04-06T14:56:53.902Z","0.2.1":"2026-05-30T21:42:00.328Z","0.3.0":"2026-08-19T13:46:41.937Z"},"bugs":{"url":"https://github.com/camcima/nestjs-memory-microservices/issues"},"author":{"name":"camcima","url":"https://github.com/camcima"},"license":"MIT","homepage":"https://github.com/camcima/nestjs-memory-microservices","keywords":["nestjs","microservices","testing","in-memory","transport","custom-transport","event-pattern","message-pattern"],"repository":{"type":"git","url":"git+https://github.com/camcima/nestjs-memory-microservices.git"},"description":"In-memory NestJS microservice transport for testing — full pipeline, zero broker","maintainers":[{"name":"camcima","email":"camcima@hotmail.com"}],"readme":"<div align=\"center\">\n\n<picture>\n  <img alt=\"nestjs-memory-microservices\" src=\"assets/logo.svg\" width=\"960\">\n</picture>\n\n<br>\n\n[![CI](https://github.com/camcima/nestjs-memory-microservices/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/camcima/nestjs-memory-microservices/actions/workflows/ci.yml)\n[![CodeQL](https://github.com/camcima/nestjs-memory-microservices/actions/workflows/codeql.yml/badge.svg?branch=main)](https://github.com/camcima/nestjs-memory-microservices/actions/workflows/codeql.yml)\n[![codecov](https://codecov.io/gh/camcima/nestjs-memory-microservices/graph/badge.svg)](https://codecov.io/gh/camcima/nestjs-memory-microservices)\n[![npm version](https://img.shields.io/npm/v/@camcima/nestjs-memory-microservices)](https://www.npmjs.com/package/@camcima/nestjs-memory-microservices)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![TypeScript](https://img.shields.io/badge/TypeScript-%E2%89%A55.0-blue.svg)](https://www.typescriptlang.org/)\n[![Node.js](https://img.shields.io/badge/Node.js-20%20%7C%2022-green.svg)](https://nodejs.org/)\n\n</div>\n\nAn in-memory NestJS microservice transport for testing. Full pipeline, zero broker.\n\n## The Problem\n\nTesting `@nestjs/microservices` handlers is painful:\n\n| Approach | Guards | Pipes | Interceptors | Filters | Broker needed? |\n|----------|--------|-------|--------------|---------|----------------|\n| Direct method call | No | No | No | No | No |\n| `ClientProxy` + emulator | Yes | Yes | Yes | Yes | **Yes** |\n| **MemoryServer** | **Yes** | **Yes** | **Yes** | **Yes** | **No** |\n\n- **Direct method calls** bypass the entire NestJS pipeline -- you're testing a function, not your microservice.\n- **Real brokers / emulators** are slow, require infrastructure, and return async fire-and-forget results you can't inspect.\n- There's no `supertest` equivalent for microservices.\n\n## How It Works\n\n`MemoryServer` is a custom transport strategy that extends `@nestjs/microservices`' `Server` base class. The `Server` class stores handler functions that are **already wrapped** with the full NestJS pipeline (guards, interceptors, pipes, exception filters). `MemoryServer` simply invokes them in-process -- no network, no broker, no emulator.\n\nYour handlers use **standard NestJS decorators** (`@EventPattern`, `@MessagePattern`, `@Payload`, `@Ctx`). Zero vendor lock-in.\n\n## Installation\n\n```bash\npnpm add -D @camcima/nestjs-memory-microservices\n```\n\n**Peer dependencies** (you probably already have these):\n\n```bash\npnpm add @nestjs/common @nestjs/core @nestjs/microservices rxjs reflect-metadata\n```\n\n## Quick Start\n\n```ts\nimport { Controller } from '@nestjs/common';\nimport { EventPattern, MessagePattern, Payload } from '@nestjs/microservices';\n\n@Controller()\nexport class OrdersController {\n  @EventPattern('order.created')\n  handleOrderCreated(@Payload() data: { orderId: string; amount: number }) {\n    console.log(`Order ${data.orderId} created for $${data.amount}`);\n  }\n\n  @MessagePattern('get.order')\n  getOrder(@Payload() data: { id: string }) {\n    return { orderId: data.id, status: 'shipped' };\n  }\n}\n```\n\n```ts\nimport { Test } from '@nestjs/testing';\nimport { MemoryServer } from '@camcima/nestjs-memory-microservices';\nimport { OrdersController } from './orders.controller';\n\ndescribe('OrdersController', () => {\n  let server: MemoryServer;\n\n  beforeAll(async () => {\n    server = new MemoryServer();\n    const module = await Test.createTestingModule({\n      controllers: [OrdersController],\n    }).compile();\n    const app = module.createNestMicroservice({ strategy: server });\n    await app.init();\n  });\n\n  it('handles events', async () => {\n    await server.emit('order.created', { orderId: '123', amount: 49.99 });\n  });\n\n  it('handles request-response', async () => {\n    const result = await server.request('get.order', { id: 'order-42' });\n    expect(result).toEqual({ orderId: 'order-42', status: 'shipped' });\n  });\n});\n```\n\nOr use the convenience helper:\n\n```ts\nimport { createTestingMicroservice } from '@camcima/nestjs-memory-microservices';\n\nconst { app, server } = await createTestingMicroservice({\n  controllers: [OrdersController],\n});\n\nawait server.emit('order.created', { orderId: '123', amount: 49.99 });\nconst result = await server.request('get.order', { id: 'order-42' });\n\nawait app.close();\n```\n\n## Documentation\n\n- [How It Works](docs/how-it-works.md) -- architecture and internals\n- [Usage Guide](docs/usage-guide.md) -- setup, patterns, and best practices\n- [Full Pipeline Testing](docs/pipeline-testing.md) -- guards, pipes, interceptors, exception filters\n- [API Reference](docs/api-reference.md) -- complete API documentation\n- [Error Handling](docs/error-handling.md) -- how errors are surfaced and tested\n- [Recipes](docs/recipes.md) -- common testing patterns and real-world examples\n- [FAQ](docs/faq.md) -- frequently asked questions\n\n## Production Usage\n\nIn production, use your real transport. The handler code is identical -- only the bootstrap changes:\n\n```ts\n// main.ts -- production\nconst app = await NestFactory.createMicroservice(AppModule, {\n  transport: Transport.RMQ,\n  options: { urls: ['amqp://localhost:5672'], queue: 'orders' },\n});\n\n// test -- swap to MemoryServer, no broker needed\nconst server = new MemoryServer();\nconst app = module.createNestMicroservice({ strategy: server });\n```\n\n## Compatibility\n\n| Dependency | Version |\n|-----------|---------|\n| Node.js | >= 20.19.0 |\n| NestJS | ^10.0.0 \\|\\| ^11.0.0 |\n| TypeScript | >= 5.0 |\n| RxJS | ^7.0.0 |\n\n## Security\n\n### CI\n\n| Tool | Purpose | Trigger |\n|------|---------|---------|\n| **CodeQL** | Static analysis for security vulnerabilities | Push/PR to `main`, weekly schedule |\n| **OSV-Scanner** | Dependency vulnerability scanning (production deps only) | Push/PR to `main` |\n| **Dependabot** | Automated dependency and GitHub Actions updates | Weekly |\n\n### Local (via Lefthook)\n\n**Gitleaks** runs automatically on every commit (`pre-commit`) to catch secrets before they reach the remote.\n\nPrerequisites: install [Gitleaks](https://github.com/gitleaks/gitleaks#installing).\n\n### Manual commands\n\n```bash\n# Dependency audit (production deps only)\npnpm run security:audit\n\n# Secret scanning\npnpm run security:secrets\n```\n\n### Optional: Semgrep\n\n[Semgrep](https://semgrep.dev/) can be used for additional local code-security scanning. It is not included in the default hooks to keep the local workflow lightweight, but can be run on demand:\n\n```bash\n# Install: https://semgrep.dev/docs/getting-started/\nsemgrep scan --config auto src/\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}