@amqp-contract/worker-nestjs 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +38 -0
- package/dist/index.cjs +84 -0
- package/dist/index.d.cts +47 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +47 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +74 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +76 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Benoit Travers
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @amqp-contract/worker-nestjs
|
|
2
|
+
|
|
3
|
+
NestJS integration for [@amqp-contract/worker](../worker). Type-safe AMQP message consumption with automatic lifecycle management.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @amqp-contract/worker-nestjs @amqp-contract/worker @amqp-contract/contract amqplib
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Module } from '@nestjs/common';
|
|
15
|
+
import { AmqpWorkerModule } from '@amqp-contract/worker-nestjs';
|
|
16
|
+
import { contract } from './contract';
|
|
17
|
+
|
|
18
|
+
@Module({
|
|
19
|
+
imports: [
|
|
20
|
+
AmqpWorkerModule.forRoot({
|
|
21
|
+
contract,
|
|
22
|
+
handlers: {
|
|
23
|
+
processOrder: async (message) => {
|
|
24
|
+
console.log('Processing order:', message.orderId);
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
connection: 'amqp://localhost',
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
})
|
|
31
|
+
export class AppModule {}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The worker automatically starts consuming messages when the module initializes and cleans up on shutdown.
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
MIT
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
let _nestjs_common = require("@nestjs/common");
|
|
2
|
+
let _amqp_contract_worker = require("@amqp-contract/worker");
|
|
3
|
+
|
|
4
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/decorateMetadata.js
|
|
5
|
+
function __decorateMetadata(k, v) {
|
|
6
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/decorateParam.js
|
|
11
|
+
function __decorateParam(paramIndex, decorator) {
|
|
12
|
+
return function(target, key) {
|
|
13
|
+
decorator(target, key, paramIndex);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/decorate.js
|
|
19
|
+
function __decorate(decorators, target, key, desc) {
|
|
20
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
21
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
22
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
23
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/worker.service.ts
|
|
28
|
+
let AmqpWorkerService = class AmqpWorkerService$1 {
|
|
29
|
+
worker = null;
|
|
30
|
+
constructor(options) {
|
|
31
|
+
this.options = options;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Initialize the worker when the NestJS module starts
|
|
35
|
+
*/
|
|
36
|
+
async onModuleInit() {
|
|
37
|
+
this.worker = await _amqp_contract_worker.TypedAmqpWorker.create({
|
|
38
|
+
contract: this.options.contract,
|
|
39
|
+
handlers: this.options.handlers,
|
|
40
|
+
connection: this.options.connection
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Close the worker when the NestJS module is destroyed
|
|
45
|
+
*/
|
|
46
|
+
async onModuleDestroy() {
|
|
47
|
+
if (this.worker) {
|
|
48
|
+
await this.worker.close();
|
|
49
|
+
this.worker = null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
AmqpWorkerService = __decorate([
|
|
54
|
+
(0, _nestjs_common.Injectable)(),
|
|
55
|
+
__decorateParam(0, (0, _nestjs_common.Inject)(MODULE_OPTIONS_TOKEN)),
|
|
56
|
+
__decorateMetadata("design:paramtypes", [Object])
|
|
57
|
+
], AmqpWorkerService);
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/worker.module.ts
|
|
61
|
+
/**
|
|
62
|
+
* ConfigurableModuleBuilder for AMQP worker module
|
|
63
|
+
* This creates forRoot and forRootAsync methods automatically
|
|
64
|
+
*/
|
|
65
|
+
const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN } = new _nestjs_common.ConfigurableModuleBuilder().setClassMethodName("forRoot").build();
|
|
66
|
+
let AmqpWorkerModule = class AmqpWorkerModule$1 extends ConfigurableModuleClass {};
|
|
67
|
+
AmqpWorkerModule = __decorate([(0, _nestjs_common.Module)({
|
|
68
|
+
providers: [AmqpWorkerService],
|
|
69
|
+
exports: [AmqpWorkerService]
|
|
70
|
+
})], AmqpWorkerModule);
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
Object.defineProperty(exports, 'AmqpWorkerModule', {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function () {
|
|
76
|
+
return AmqpWorkerModule;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
Object.defineProperty(exports, 'AmqpWorkerService', {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function () {
|
|
82
|
+
return AmqpWorkerService;
|
|
83
|
+
}
|
|
84
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as _nestjs_common0 from "@nestjs/common";
|
|
2
|
+
import { OnModuleDestroy, OnModuleInit } from "@nestjs/common";
|
|
3
|
+
import { Options } from "amqplib";
|
|
4
|
+
import { ContractDefinition, WorkerInferConsumerHandlers } from "@amqp-contract/contract";
|
|
5
|
+
|
|
6
|
+
//#region src/worker.service.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Options for creating a NestJS worker service
|
|
9
|
+
*/
|
|
10
|
+
interface AmqpWorkerModuleOptions<TContract extends ContractDefinition> {
|
|
11
|
+
contract: TContract;
|
|
12
|
+
handlers: WorkerInferConsumerHandlers<TContract>;
|
|
13
|
+
connection: string | Options.Connect;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Type-safe AMQP worker service for NestJS
|
|
17
|
+
* This service integrates @amqp-contract/worker with NestJS lifecycle
|
|
18
|
+
*/
|
|
19
|
+
declare class AmqpWorkerService<TContract extends ContractDefinition> implements OnModuleInit, OnModuleDestroy {
|
|
20
|
+
private readonly options;
|
|
21
|
+
private worker;
|
|
22
|
+
constructor(options: AmqpWorkerModuleOptions<TContract>);
|
|
23
|
+
/**
|
|
24
|
+
* Initialize the worker when the NestJS module starts
|
|
25
|
+
*/
|
|
26
|
+
onModuleInit(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Close the worker when the NestJS module is destroyed
|
|
29
|
+
*/
|
|
30
|
+
onModuleDestroy(): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/worker.module.d.ts
|
|
34
|
+
/**
|
|
35
|
+
* ConfigurableModuleBuilder for AMQP worker module
|
|
36
|
+
* This creates forRoot and forRootAsync methods automatically
|
|
37
|
+
*/
|
|
38
|
+
declare const ConfigurableModuleClass: _nestjs_common0.ConfigurableModuleCls<AmqpWorkerModuleOptions<never>, "forRoot", "create", {}>, MODULE_OPTIONS_TOKEN: string | symbol;
|
|
39
|
+
/**
|
|
40
|
+
* NestJS module for AMQP worker integration
|
|
41
|
+
* This module provides type-safe AMQP worker functionality using @amqp-contract/worker
|
|
42
|
+
* without relying on NestJS decorators (except for dependency injection)
|
|
43
|
+
*/
|
|
44
|
+
declare class AmqpWorkerModule extends ConfigurableModuleClass {}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { AmqpWorkerModule, type AmqpWorkerModuleOptions, AmqpWorkerService };
|
|
47
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/worker.service.ts","../src/worker.module.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AASiB,UAAA,uBAAuB,CAAA,kBAAmB,kBAAnB,CAAA,CAAA;EAAmB,QAAA,EAC/C,SAD+C;EAC/C,QAAA,EACA,2BADA,CAC4B,SAD5B,CAAA;EAC4B,UAAA,EAAA,MAAA,GACjB,OAAA,CAAQ,OADS;;;;AAQxC;;AAQsD,cAPzC,iBAOyC,CAAA,kBAPL,kBAOK,CAAA,YANzC,YAMyC,EAN3B,eAM2B,CAAA;EAAxB,iBAAA,OAAA;EAMN,QAAA,MAAA;EAWG,WAAA,CAAA,OAAA,EAjBG,uBAiBH,CAjB2B,SAiB3B,CAAA;EAvBd;;;kBAYW;;;ACzBxB;EAea,eAAA,CAAA,CAAA,EDqBc,OCrBG,CAAA,IAAQ,CAAA;;;;;;;;cAfvB,yBAAuB,eAAA,CAAA,sBAAA;ADCtC;;;;;AAGuB,cCWV,gBAAA,SAAyB,uBAAA,CDXP"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as _nestjs_common0 from "@nestjs/common";
|
|
2
|
+
import { OnModuleDestroy, OnModuleInit } from "@nestjs/common";
|
|
3
|
+
import { Options } from "amqplib";
|
|
4
|
+
import { ContractDefinition, WorkerInferConsumerHandlers } from "@amqp-contract/contract";
|
|
5
|
+
|
|
6
|
+
//#region src/worker.service.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Options for creating a NestJS worker service
|
|
9
|
+
*/
|
|
10
|
+
interface AmqpWorkerModuleOptions<TContract extends ContractDefinition> {
|
|
11
|
+
contract: TContract;
|
|
12
|
+
handlers: WorkerInferConsumerHandlers<TContract>;
|
|
13
|
+
connection: string | Options.Connect;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Type-safe AMQP worker service for NestJS
|
|
17
|
+
* This service integrates @amqp-contract/worker with NestJS lifecycle
|
|
18
|
+
*/
|
|
19
|
+
declare class AmqpWorkerService<TContract extends ContractDefinition> implements OnModuleInit, OnModuleDestroy {
|
|
20
|
+
private readonly options;
|
|
21
|
+
private worker;
|
|
22
|
+
constructor(options: AmqpWorkerModuleOptions<TContract>);
|
|
23
|
+
/**
|
|
24
|
+
* Initialize the worker when the NestJS module starts
|
|
25
|
+
*/
|
|
26
|
+
onModuleInit(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Close the worker when the NestJS module is destroyed
|
|
29
|
+
*/
|
|
30
|
+
onModuleDestroy(): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/worker.module.d.ts
|
|
34
|
+
/**
|
|
35
|
+
* ConfigurableModuleBuilder for AMQP worker module
|
|
36
|
+
* This creates forRoot and forRootAsync methods automatically
|
|
37
|
+
*/
|
|
38
|
+
declare const ConfigurableModuleClass: _nestjs_common0.ConfigurableModuleCls<AmqpWorkerModuleOptions<never>, "forRoot", "create", {}>, MODULE_OPTIONS_TOKEN: string | symbol;
|
|
39
|
+
/**
|
|
40
|
+
* NestJS module for AMQP worker integration
|
|
41
|
+
* This module provides type-safe AMQP worker functionality using @amqp-contract/worker
|
|
42
|
+
* without relying on NestJS decorators (except for dependency injection)
|
|
43
|
+
*/
|
|
44
|
+
declare class AmqpWorkerModule extends ConfigurableModuleClass {}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { AmqpWorkerModule, type AmqpWorkerModuleOptions, AmqpWorkerService };
|
|
47
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/worker.service.ts","../src/worker.module.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AASiB,UAAA,uBAAuB,CAAA,kBAAmB,kBAAnB,CAAA,CAAA;EAAmB,QAAA,EAC/C,SAD+C;EAC/C,QAAA,EACA,2BADA,CAC4B,SAD5B,CAAA;EAC4B,UAAA,EAAA,MAAA,GACjB,OAAA,CAAQ,OADS;;;;AAQxC;;AAQsD,cAPzC,iBAOyC,CAAA,kBAPL,kBAOK,CAAA,YANzC,YAMyC,EAN3B,eAM2B,CAAA;EAAxB,iBAAA,OAAA;EAMN,QAAA,MAAA;EAWG,WAAA,CAAA,OAAA,EAjBG,uBAiBH,CAjB2B,SAiB3B,CAAA;EAvBd;;;kBAYW;;;ACzBxB;EAea,eAAA,CAAA,CAAA,EDqBc,OCrBG,CAAA,IAAQ,CAAA;;;;;;;;cAfvB,yBAAuB,eAAA,CAAA,sBAAA;ADCtC;;;;;AAGuB,cCWV,gBAAA,SAAyB,uBAAA,CDXP"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ConfigurableModuleBuilder, Inject, Injectable, Module } from "@nestjs/common";
|
|
2
|
+
import { TypedAmqpWorker } from "@amqp-contract/worker";
|
|
3
|
+
|
|
4
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/decorateMetadata.js
|
|
5
|
+
function __decorateMetadata(k, v) {
|
|
6
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/decorateParam.js
|
|
11
|
+
function __decorateParam(paramIndex, decorator) {
|
|
12
|
+
return function(target, key) {
|
|
13
|
+
decorator(target, key, paramIndex);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/decorate.js
|
|
19
|
+
function __decorate(decorators, target, key, desc) {
|
|
20
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
21
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
22
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
23
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/worker.service.ts
|
|
28
|
+
let AmqpWorkerService = class AmqpWorkerService$1 {
|
|
29
|
+
worker = null;
|
|
30
|
+
constructor(options) {
|
|
31
|
+
this.options = options;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Initialize the worker when the NestJS module starts
|
|
35
|
+
*/
|
|
36
|
+
async onModuleInit() {
|
|
37
|
+
this.worker = await TypedAmqpWorker.create({
|
|
38
|
+
contract: this.options.contract,
|
|
39
|
+
handlers: this.options.handlers,
|
|
40
|
+
connection: this.options.connection
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Close the worker when the NestJS module is destroyed
|
|
45
|
+
*/
|
|
46
|
+
async onModuleDestroy() {
|
|
47
|
+
if (this.worker) {
|
|
48
|
+
await this.worker.close();
|
|
49
|
+
this.worker = null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
AmqpWorkerService = __decorate([
|
|
54
|
+
Injectable(),
|
|
55
|
+
__decorateParam(0, Inject(MODULE_OPTIONS_TOKEN)),
|
|
56
|
+
__decorateMetadata("design:paramtypes", [Object])
|
|
57
|
+
], AmqpWorkerService);
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/worker.module.ts
|
|
61
|
+
/**
|
|
62
|
+
* ConfigurableModuleBuilder for AMQP worker module
|
|
63
|
+
* This creates forRoot and forRootAsync methods automatically
|
|
64
|
+
*/
|
|
65
|
+
const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN } = new ConfigurableModuleBuilder().setClassMethodName("forRoot").build();
|
|
66
|
+
let AmqpWorkerModule = class AmqpWorkerModule$1 extends ConfigurableModuleClass {};
|
|
67
|
+
AmqpWorkerModule = __decorate([Module({
|
|
68
|
+
providers: [AmqpWorkerService],
|
|
69
|
+
exports: [AmqpWorkerService]
|
|
70
|
+
})], AmqpWorkerModule);
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
export { AmqpWorkerModule, AmqpWorkerService };
|
|
74
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["AmqpWorkerService","options: AmqpWorkerModuleOptions<TContract>","AmqpWorkerModule"],"sources":["../src/worker.service.ts","../src/worker.module.ts"],"sourcesContent":["import { Inject, Injectable, type OnModuleDestroy, type OnModuleInit } from \"@nestjs/common\";\nimport type { Options } from \"amqplib\";\nimport type { ContractDefinition, WorkerInferConsumerHandlers } from \"@amqp-contract/contract\";\nimport { TypedAmqpWorker } from \"@amqp-contract/worker\";\nimport { MODULE_OPTIONS_TOKEN } from \"./worker.module.js\";\n\n/**\n * Options for creating a NestJS worker service\n */\nexport interface AmqpWorkerModuleOptions<TContract extends ContractDefinition> {\n contract: TContract;\n handlers: WorkerInferConsumerHandlers<TContract>;\n connection: string | Options.Connect;\n}\n\n/**\n * Type-safe AMQP worker service for NestJS\n * This service integrates @amqp-contract/worker with NestJS lifecycle\n */\n@Injectable()\nexport class AmqpWorkerService<TContract extends ContractDefinition>\n implements OnModuleInit, OnModuleDestroy\n{\n private worker: TypedAmqpWorker<TContract> | null = null;\n\n constructor(\n @Inject(MODULE_OPTIONS_TOKEN)\n private readonly options: AmqpWorkerModuleOptions<TContract>,\n ) {}\n\n /**\n * Initialize the worker when the NestJS module starts\n */\n async onModuleInit(): Promise<void> {\n this.worker = await TypedAmqpWorker.create({\n contract: this.options.contract,\n handlers: this.options.handlers,\n connection: this.options.connection,\n });\n }\n\n /**\n * Close the worker when the NestJS module is destroyed\n */\n async onModuleDestroy(): Promise<void> {\n if (this.worker) {\n await this.worker.close();\n this.worker = null;\n }\n }\n}\n","import { ConfigurableModuleBuilder, Module } from \"@nestjs/common\";\nimport type { AmqpWorkerModuleOptions } from \"./worker.service.js\";\nimport { AmqpWorkerService } from \"./worker.service.js\";\n\n/**\n * ConfigurableModuleBuilder for AMQP worker module\n * This creates forRoot and forRootAsync methods automatically\n */\nexport const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN } = new ConfigurableModuleBuilder<\n AmqpWorkerModuleOptions<never>\n>()\n .setClassMethodName(\"forRoot\")\n .build();\n\n/**\n * NestJS module for AMQP worker integration\n * This module provides type-safe AMQP worker functionality using @amqp-contract/worker\n * without relying on NestJS decorators (except for dependency injection)\n */\n@Module({\n providers: [AmqpWorkerService],\n exports: [AmqpWorkerService],\n})\nexport class AmqpWorkerModule extends ConfigurableModuleClass {}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBO,8BAAMA,oBAEb;CACE,AAAQ,SAA4C;CAEpD,YACE,AACiBC,SACjB;EADiB;;;;;CAMnB,MAAM,eAA8B;AAClC,OAAK,SAAS,MAAM,gBAAgB,OAAO;GACzC,UAAU,KAAK,QAAQ;GACvB,UAAU,KAAK,QAAQ;GACvB,YAAY,KAAK,QAAQ;GAC1B,CAAC;;;;;CAMJ,MAAM,kBAAiC;AACrC,MAAI,KAAK,QAAQ;AACf,SAAM,KAAK,OAAO,OAAO;AACzB,QAAK,SAAS;;;;;CA5BnB,YAAY;oBAOR,OAAO,qBAAqB;;;;;;;;;;AClBjC,MAAa,EAAE,yBAAyB,yBAAyB,IAAI,2BAElE,CACA,mBAAmB,UAAU,CAC7B,OAAO;AAWH,6BAAMC,2BAAyB,wBAAwB;+BAJ7D,OAAO;CACN,WAAW,CAAC,kBAAkB;CAC9B,SAAS,CAAC,kBAAkB;CAC7B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@amqp-contract/worker-nestjs",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "NestJS integration for @amqp-contract/worker",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"amqp",
|
|
7
|
+
"contract",
|
|
8
|
+
"nestjs",
|
|
9
|
+
"rabbitmq",
|
|
10
|
+
"typescript",
|
|
11
|
+
"worker"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/btravers/amqp-contract#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/btravers/amqp-contract/issues"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/btravers/amqp-contract.git",
|
|
20
|
+
"directory": "packages/worker-nestjs"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"author": "Benoit TRAVERS <benoit.travers.fr@gmail.com>",
|
|
24
|
+
"type": "module",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"import": {
|
|
28
|
+
"types": "./dist/index.d.mts",
|
|
29
|
+
"default": "./dist/index.mjs"
|
|
30
|
+
},
|
|
31
|
+
"require": {
|
|
32
|
+
"types": "./dist/index.d.cts",
|
|
33
|
+
"default": "./dist/index.cjs"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"./package.json": "./package.json"
|
|
37
|
+
},
|
|
38
|
+
"main": "./dist/index.cjs",
|
|
39
|
+
"module": "./dist/index.mjs",
|
|
40
|
+
"types": "./dist/index.d.mts",
|
|
41
|
+
"files": [
|
|
42
|
+
"dist"
|
|
43
|
+
],
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@amqp-contract/contract": "0.0.6",
|
|
46
|
+
"@amqp-contract/worker": "0.0.6"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@nestjs/common": "11.0.10",
|
|
50
|
+
"@types/amqplib": "0.10.8",
|
|
51
|
+
"@types/node": "25.0.3",
|
|
52
|
+
"@vitest/coverage-v8": "4.0.16",
|
|
53
|
+
"amqplib": "0.10.9",
|
|
54
|
+
"reflect-metadata": "0.2.2",
|
|
55
|
+
"rxjs": "7.8.1",
|
|
56
|
+
"tsdown": "0.18.1",
|
|
57
|
+
"typescript": "5.9.3",
|
|
58
|
+
"vitest": "4.0.16",
|
|
59
|
+
"zod": "4.2.1",
|
|
60
|
+
"@amqp-contract/tsconfig": "0.0.0"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"@nestjs/common": "^11.0.0",
|
|
64
|
+
"@nestjs/core": "^11.0.0",
|
|
65
|
+
"amqplib": ">=0.10.0",
|
|
66
|
+
"reflect-metadata": ">=0.1.13",
|
|
67
|
+
"rxjs": ">=7.0.0"
|
|
68
|
+
},
|
|
69
|
+
"scripts": {
|
|
70
|
+
"build": "tsdown src/index.ts --format cjs,esm --dts --clean",
|
|
71
|
+
"dev": "tsdown src/index.ts --format cjs,esm --dts --watch",
|
|
72
|
+
"test": "vitest run --project unit",
|
|
73
|
+
"test:watch": "vitest --project unit",
|
|
74
|
+
"typecheck": "tsc --noEmit"
|
|
75
|
+
}
|
|
76
|
+
}
|