trucostars-core-module 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 +423 -0
- package/dist/app.controller.d.ts +6 -0
- package/dist/app.controller.js +43 -0
- package/dist/app.controller.js.map +1 -0
- package/dist/app.module.d.ts +4 -0
- package/dist/app.module.js +31 -0
- package/dist/app.module.js.map +1 -0
- package/dist/app.service.d.ts +5 -0
- package/dist/app.service.js +28 -0
- package/dist/app.service.js.map +1 -0
- package/dist/common/common.module.d.ts +2 -0
- package/dist/common/common.module.js +58 -0
- package/dist/common/common.module.js.map +1 -0
- package/dist/common/config/env.validation.d.ts +2 -0
- package/dist/common/config/env.validation.js +93 -0
- package/dist/common/config/env.validation.js.map +1 -0
- package/dist/common/config/firebase.config.d.ts +2 -0
- package/dist/common/config/firebase.config.js +9 -0
- package/dist/common/config/firebase.config.js.map +1 -0
- package/dist/common/config/index.d.ts +1 -0
- package/dist/common/config/index.js +18 -0
- package/dist/common/config/index.js.map +1 -0
- package/dist/common/database/database.module.d.ts +2 -0
- package/dist/common/database/database.module.js +54 -0
- package/dist/common/database/database.module.js.map +1 -0
- package/dist/common/database/database.service.d.ts +25 -0
- package/dist/common/database/database.service.js +91 -0
- package/dist/common/database/database.service.js.map +1 -0
- package/dist/common/decorators/api-performance.decorator.d.ts +1 -0
- package/dist/common/decorators/api-performance.decorator.js +42 -0
- package/dist/common/decorators/api-performance.decorator.js.map +1 -0
- package/dist/common/decorators/index.d.ts +1 -0
- package/dist/common/decorators/index.js +18 -0
- package/dist/common/decorators/index.js.map +1 -0
- package/dist/common/filters/all-exceptions.filter.d.ts +5 -0
- package/dist/common/filters/all-exceptions.filter.js +38 -0
- package/dist/common/filters/all-exceptions.filter.js.map +1 -0
- package/dist/common/firebase/firebase.controller.d.ts +35 -0
- package/dist/common/firebase/firebase.controller.js +115 -0
- package/dist/common/firebase/firebase.controller.js.map +1 -0
- package/dist/common/firebase/firebase.module.d.ts +3 -0
- package/dist/common/firebase/firebase.module.js +83 -0
- package/dist/common/firebase/firebase.module.js.map +1 -0
- package/dist/common/firebase/firebase.service.d.ts +17 -0
- package/dist/common/firebase/firebase.service.js +127 -0
- package/dist/common/firebase/firebase.service.js.map +1 -0
- package/dist/common/firebase/firebase.types.d.ts +22 -0
- package/dist/common/firebase/firebase.types.js +3 -0
- package/dist/common/firebase/firebase.types.js.map +1 -0
- package/dist/common/interceptors/logging.interceptor.d.ts +10 -0
- package/dist/common/interceptors/logging.interceptor.js +108 -0
- package/dist/common/interceptors/logging.interceptor.js.map +1 -0
- package/dist/common/interceptors/performance.interceptor.d.ts +7 -0
- package/dist/common/interceptors/performance.interceptor.js +58 -0
- package/dist/common/interceptors/performance.interceptor.js.map +1 -0
- package/dist/common/middleware/logger.middleware.d.ts +19 -0
- package/dist/common/middleware/logger.middleware.js +231 -0
- package/dist/common/middleware/logger.middleware.js.map +1 -0
- package/dist/common/redis/redis.module.d.ts +2 -0
- package/dist/common/redis/redis.module.js +21 -0
- package/dist/common/redis/redis.module.js.map +1 -0
- package/dist/common/redis/redis.service.d.ts +11 -0
- package/dist/common/redis/redis.service.js +52 -0
- package/dist/common/redis/redis.service.js.map +1 -0
- package/dist/common/sqs/sqs.consumer.d.ts +20 -0
- package/dist/common/sqs/sqs.consumer.js +140 -0
- package/dist/common/sqs/sqs.consumer.js.map +1 -0
- package/dist/common/sqs/sqs.controller.d.ts +21 -0
- package/dist/common/sqs/sqs.controller.js +70 -0
- package/dist/common/sqs/sqs.controller.js.map +1 -0
- package/dist/common/sqs/sqs.example.service.d.ts +27 -0
- package/dist/common/sqs/sqs.example.service.js +206 -0
- package/dist/common/sqs/sqs.example.service.js.map +1 -0
- package/dist/common/sqs/sqs.module.d.ts +2 -0
- package/dist/common/sqs/sqs.module.js +24 -0
- package/dist/common/sqs/sqs.module.js.map +1 -0
- package/dist/common/sqs/sqs.producer.d.ts +13 -0
- package/dist/common/sqs/sqs.producer.js +197 -0
- package/dist/common/sqs/sqs.producer.js.map +1 -0
- package/dist/common/websocket/websocket.gateway.d.ts +9 -0
- package/dist/common/websocket/websocket.gateway.js +41 -0
- package/dist/common/websocket/websocket.gateway.js.map +1 -0
- package/dist/common/websocket/websocket.module.d.ts +2 -0
- package/dist/common/websocket/websocket.module.js +22 -0
- package/dist/common/websocket/websocket.module.js.map +1 -0
- package/dist/common/websocket/websocket.service.d.ts +25 -0
- package/dist/common/websocket/websocket.service.js +248 -0
- package/dist/common/websocket/websocket.service.js.map +1 -0
- package/dist/data/data.d.ts +10 -0
- package/dist/data/data.js +10 -0
- package/dist/data/data.js.map +1 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +48 -0
- package/dist/main.js.map +1 -0
- package/dist/products/entities/product.entity.d.ts +56 -0
- package/dist/products/entities/product.entity.js +80 -0
- package/dist/products/entities/product.entity.js.map +1 -0
- package/dist/products/products.controller.d.ts +35 -0
- package/dist/products/products.controller.js +98 -0
- package/dist/products/products.controller.js.map +1 -0
- package/dist/products/products.module.d.ts +2 -0
- package/dist/products/products.module.js +27 -0
- package/dist/products/products.module.js.map +1 -0
- package/dist/products/products.service.d.ts +36 -0
- package/dist/products/products.service.example.d.ts +1 -0
- package/dist/products/products.service.example.js +3 -0
- package/dist/products/products.service.example.js.map +1 -0
- package/dist/products/products.service.js +74 -0
- package/dist/products/products.service.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +106 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var LoggerMiddleware_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.LoggerMiddleware = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const crypto_1 = require("crypto");
|
|
13
|
+
let LoggerMiddleware = class LoggerMiddleware {
|
|
14
|
+
static { LoggerMiddleware_1 = this; }
|
|
15
|
+
logger = new common_1.Logger('HTTP');
|
|
16
|
+
isEnabled = process.env.ENABLE_HTTP_LOGGING !== 'false';
|
|
17
|
+
static concurrentRequests = 0;
|
|
18
|
+
use(req, res, next) {
|
|
19
|
+
if (!this.isEnabled) {
|
|
20
|
+
next();
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
LoggerMiddleware_1.concurrentRequests++;
|
|
24
|
+
const currentConcurrent = LoggerMiddleware_1.concurrentRequests;
|
|
25
|
+
const { method, originalUrl, ip } = req;
|
|
26
|
+
const userAgent = req.get('user-agent') || '';
|
|
27
|
+
const startTime = Date.now();
|
|
28
|
+
const requestId = (0, crypto_1.randomUUID)().split('-')[0];
|
|
29
|
+
const startMemory = process.memoryUsage();
|
|
30
|
+
const startCpu = process.cpuUsage();
|
|
31
|
+
req.dbQueryCount = 0;
|
|
32
|
+
let responseSize = 0;
|
|
33
|
+
const originalWrite = res.write.bind(res);
|
|
34
|
+
const originalEnd = res.end.bind(res);
|
|
35
|
+
res.write = function (chunk, ...args) {
|
|
36
|
+
if (chunk) {
|
|
37
|
+
if (typeof chunk === 'string') {
|
|
38
|
+
responseSize += Buffer.byteLength(chunk, 'utf8');
|
|
39
|
+
}
|
|
40
|
+
else if (Buffer.isBuffer(chunk)) {
|
|
41
|
+
responseSize += chunk.length;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
responseSize += Buffer.byteLength(JSON.stringify(chunk), 'utf8');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return originalWrite(chunk, ...args);
|
|
48
|
+
};
|
|
49
|
+
res.end = function (chunk, ...args) {
|
|
50
|
+
if (chunk) {
|
|
51
|
+
if (typeof chunk === 'string') {
|
|
52
|
+
responseSize += Buffer.byteLength(chunk, 'utf8');
|
|
53
|
+
}
|
|
54
|
+
else if (Buffer.isBuffer(chunk)) {
|
|
55
|
+
responseSize += chunk.length;
|
|
56
|
+
}
|
|
57
|
+
else if (typeof chunk === 'object') {
|
|
58
|
+
responseSize += Buffer.byteLength(JSON.stringify(chunk), 'utf8');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return originalEnd(chunk, ...args);
|
|
62
|
+
};
|
|
63
|
+
const incomingLog = [
|
|
64
|
+
'\n' + '═'.repeat(80),
|
|
65
|
+
`📥 INCOMING REQUEST`,
|
|
66
|
+
` Request ID: 🔖 ${requestId}`,
|
|
67
|
+
` Method: ${this.colorizeMethod(method)}`,
|
|
68
|
+
` URL: ${originalUrl}`,
|
|
69
|
+
` IP: ${ip}`,
|
|
70
|
+
` User-Agent: ${this.truncateUserAgent(userAgent)}`,
|
|
71
|
+
` Time: ${new Date().toISOString()}`,
|
|
72
|
+
` Memory: 💾 ${this.formatMemory(startMemory.heapUsed)}`,
|
|
73
|
+
'─'.repeat(80),
|
|
74
|
+
].join('\n');
|
|
75
|
+
this.logger.log(incomingLog);
|
|
76
|
+
res.on('finish', () => {
|
|
77
|
+
LoggerMiddleware_1.concurrentRequests--;
|
|
78
|
+
const { statusCode } = res;
|
|
79
|
+
const responseTime = Date.now() - startTime;
|
|
80
|
+
const endMemory = process.memoryUsage();
|
|
81
|
+
const endCpu = process.cpuUsage(startCpu);
|
|
82
|
+
const memoryDelta = endMemory.heapUsed - startMemory.heapUsed;
|
|
83
|
+
const cpuTime = (endCpu.user + endCpu.system) / 1000;
|
|
84
|
+
const dbQueries = req.dbQueryCount || 0;
|
|
85
|
+
const statusEmoji = this.getStatusEmoji(statusCode);
|
|
86
|
+
const statusColor = this.getStatusColor(statusCode);
|
|
87
|
+
const statusText = this.getStatusText(statusCode);
|
|
88
|
+
const performanceLevel = this.getPerformanceLevel(responseTime);
|
|
89
|
+
const outgoingLog = [
|
|
90
|
+
`${statusEmoji} RESPONSE SENT`,
|
|
91
|
+
` Request ID: 🔖 ${requestId}`,
|
|
92
|
+
` Method: ${this.colorizeMethod(method)}`,
|
|
93
|
+
` URL: ${originalUrl}`,
|
|
94
|
+
` Status: ${statusColor} ${statusCode} - ${statusText}`,
|
|
95
|
+
` Response Time: ${this.formatResponseTime(responseTime)} ${performanceLevel}`,
|
|
96
|
+
` Size: ${this.formatBytes(responseSize)}${statusCode === 304 ? ' (No Content - Cache)' : ''}`,
|
|
97
|
+
'─'.repeat(80),
|
|
98
|
+
`📊 INTERNAL METRICS`,
|
|
99
|
+
` Concurrent: 📈 ${currentConcurrent} ${currentConcurrent === 1 ? 'request' : 'requests'} ${this.getConcurrentLevel(currentConcurrent)}`,
|
|
100
|
+
` CPU Time: ⚙️ ${this.formatResponseTime(cpuTime)}`,
|
|
101
|
+
` Memory Used: 💾 ${this.formatMemoryDelta(memoryDelta)}`,
|
|
102
|
+
` DB Queries: 🗄️ ${dbQueries} ${dbQueries === 0 ? '(No queries)' : dbQueries === 1 ? 'query' : 'queries'}`,
|
|
103
|
+
'═'.repeat(80) + '\n',
|
|
104
|
+
].join('\n');
|
|
105
|
+
if (statusCode >= 500) {
|
|
106
|
+
this.logger.error(outgoingLog);
|
|
107
|
+
}
|
|
108
|
+
else if (statusCode >= 400) {
|
|
109
|
+
this.logger.warn(outgoingLog);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
this.logger.log(outgoingLog);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
next();
|
|
116
|
+
}
|
|
117
|
+
colorizeMethod(method) {
|
|
118
|
+
const colors = {
|
|
119
|
+
GET: '🟢 GET',
|
|
120
|
+
POST: '🔵 POST',
|
|
121
|
+
PUT: '🟡 PUT',
|
|
122
|
+
PATCH: '🟠 PATCH',
|
|
123
|
+
DELETE: '🔴 DELETE',
|
|
124
|
+
};
|
|
125
|
+
return colors[method] || method;
|
|
126
|
+
}
|
|
127
|
+
getStatusEmoji(statusCode) {
|
|
128
|
+
if (statusCode >= 500)
|
|
129
|
+
return '❌';
|
|
130
|
+
if (statusCode >= 400)
|
|
131
|
+
return '⚠️';
|
|
132
|
+
if (statusCode >= 300)
|
|
133
|
+
return '↩️';
|
|
134
|
+
if (statusCode >= 200)
|
|
135
|
+
return '✅';
|
|
136
|
+
return '📤';
|
|
137
|
+
}
|
|
138
|
+
getStatusColor(statusCode) {
|
|
139
|
+
if (statusCode >= 500)
|
|
140
|
+
return '🔴';
|
|
141
|
+
if (statusCode >= 400)
|
|
142
|
+
return '🟡';
|
|
143
|
+
if (statusCode >= 300)
|
|
144
|
+
return '🔵';
|
|
145
|
+
if (statusCode >= 200)
|
|
146
|
+
return '🟢';
|
|
147
|
+
return '⚪';
|
|
148
|
+
}
|
|
149
|
+
getStatusText(statusCode) {
|
|
150
|
+
const statusTexts = {
|
|
151
|
+
200: 'OK',
|
|
152
|
+
201: 'Created',
|
|
153
|
+
202: 'Accepted',
|
|
154
|
+
204: 'No Content',
|
|
155
|
+
301: 'Moved Permanently',
|
|
156
|
+
302: 'Found',
|
|
157
|
+
304: 'Not Modified (Cache Hit)',
|
|
158
|
+
307: 'Temporary Redirect',
|
|
159
|
+
308: 'Permanent Redirect',
|
|
160
|
+
400: 'Bad Request',
|
|
161
|
+
401: 'Unauthorized',
|
|
162
|
+
403: 'Forbidden',
|
|
163
|
+
404: 'Not Found',
|
|
164
|
+
405: 'Method Not Allowed',
|
|
165
|
+
409: 'Conflict',
|
|
166
|
+
422: 'Unprocessable Entity',
|
|
167
|
+
429: 'Too Many Requests',
|
|
168
|
+
500: 'Internal Server Error',
|
|
169
|
+
501: 'Not Implemented',
|
|
170
|
+
502: 'Bad Gateway',
|
|
171
|
+
503: 'Service Unavailable',
|
|
172
|
+
504: 'Gateway Timeout',
|
|
173
|
+
};
|
|
174
|
+
return statusTexts[statusCode] || 'Unknown Status';
|
|
175
|
+
}
|
|
176
|
+
formatResponseTime(ms) {
|
|
177
|
+
if (ms < 100)
|
|
178
|
+
return `${ms}ms`;
|
|
179
|
+
if (ms < 1000)
|
|
180
|
+
return `${ms}ms`;
|
|
181
|
+
return `${(ms / 1000).toFixed(2)}s`;
|
|
182
|
+
}
|
|
183
|
+
getPerformanceLevel(ms) {
|
|
184
|
+
if (ms < 100)
|
|
185
|
+
return '⚡ Fast';
|
|
186
|
+
if (ms < 500)
|
|
187
|
+
return '✅ Normal';
|
|
188
|
+
if (ms < 1000)
|
|
189
|
+
return '⏱️ Slow';
|
|
190
|
+
return '🐌 Very Slow';
|
|
191
|
+
}
|
|
192
|
+
formatBytes(bytes) {
|
|
193
|
+
if (bytes === 0)
|
|
194
|
+
return '0 B';
|
|
195
|
+
const k = 1024;
|
|
196
|
+
const sizes = ['B', 'KB', 'MB', 'GB'];
|
|
197
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
198
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
|
|
199
|
+
}
|
|
200
|
+
truncateUserAgent(userAgent) {
|
|
201
|
+
return userAgent.length > 60 ? userAgent.substring(0, 57) + '...' : userAgent;
|
|
202
|
+
}
|
|
203
|
+
formatMemory(bytes) {
|
|
204
|
+
const mb = bytes / 1024 / 1024;
|
|
205
|
+
return `${mb.toFixed(2)} MB`;
|
|
206
|
+
}
|
|
207
|
+
formatMemoryDelta(bytes) {
|
|
208
|
+
const mb = bytes / 1024 / 1024;
|
|
209
|
+
const sign = bytes >= 0 ? '+' : '';
|
|
210
|
+
const emoji = bytes > 5 * 1024 * 1024 ? '⚠️' : bytes < 0 ? '✅' : '';
|
|
211
|
+
return `${sign}${mb.toFixed(2)} MB ${emoji}`;
|
|
212
|
+
}
|
|
213
|
+
getConcurrentLevel(concurrent) {
|
|
214
|
+
if (concurrent === 1)
|
|
215
|
+
return '';
|
|
216
|
+
if (concurrent < 5)
|
|
217
|
+
return '';
|
|
218
|
+
if (concurrent < 10)
|
|
219
|
+
return '⚠️';
|
|
220
|
+
if (concurrent < 20)
|
|
221
|
+
return '🔥';
|
|
222
|
+
if (concurrent < 50)
|
|
223
|
+
return '☢️';
|
|
224
|
+
return '☢️';
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
exports.LoggerMiddleware = LoggerMiddleware;
|
|
228
|
+
exports.LoggerMiddleware = LoggerMiddleware = LoggerMiddleware_1 = __decorate([
|
|
229
|
+
(0, common_1.Injectable)()
|
|
230
|
+
], LoggerMiddleware);
|
|
231
|
+
//# sourceMappingURL=logger.middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.middleware.js","sourceRoot":"","sources":["../../../src/common/middleware/logger.middleware.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoE;AAEpE,mCAAoC;AAG7B,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;;IACnB,MAAM,GAAG,IAAI,eAAM,CAAC,MAAM,CAAC,CAAC;IAC5B,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,KAAK,OAAO,CAAC;IACxD,MAAM,CAAC,kBAAkB,GAAG,CAAC,CAAC;IAEtC,GAAG,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB;QAEjD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,IAAI,EAAE,CAAC;YACP,OAAO;QACT,CAAC;QAGD,kBAAgB,CAAC,kBAAkB,EAAE,CAAC;QACtC,MAAM,iBAAiB,GAAG,kBAAgB,CAAC,kBAAkB,CAAC;QAE9D,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,GAAG,GAAG,CAAC;QACxC,MAAM,SAAS,GAAG,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC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C,MAAM,EAAE,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC;QAC/B,MAAM,IAAI,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACnC,MAAM,KAAK,GAAG,KAAK,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACpE,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,KAAK,EAAE,CAAC;IAC/C,CAAC;IAEO,kBAAkB,CAAC,UAAkB;QAC3C,IAAI,UAAU,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QAChC,IAAI,UAAU,GAAG,CAAC;YAAE,OAAO,EAAE,CAAC;QAC9B,IAAI,UAAU,GAAG,EAAE;YAAE,OAAO,IAAI,CAAC;QACjC,IAAI,UAAU,GAAG,EAAE;YAAE,OAAO,IAAI,CAAC;QACjC,IAAI,UAAU,GAAG,EAAE;YAAE,OAAO,IAAI,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;;AAzOU,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;GACA,gBAAgB,CA0O5B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.RedisModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const redis_service_1 = require("./redis.service");
|
|
12
|
+
let RedisModule = class RedisModule {
|
|
13
|
+
};
|
|
14
|
+
exports.RedisModule = RedisModule;
|
|
15
|
+
exports.RedisModule = RedisModule = __decorate([
|
|
16
|
+
(0, common_1.Module)({
|
|
17
|
+
providers: [redis_service_1.RedisService],
|
|
18
|
+
exports: [redis_service_1.RedisService],
|
|
19
|
+
})
|
|
20
|
+
], RedisModule);
|
|
21
|
+
//# sourceMappingURL=redis.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.module.js","sourceRoot":"","sources":["../../../src/common/redis/redis.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,mDAA+C;AAMxC,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IAJvB,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,4BAAY,CAAC;QACzB,OAAO,EAAE,CAAC,4BAAY,CAAC;KACxB,CAAC;GACW,WAAW,CAAG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OnModuleDestroy, OnModuleInit } from '@nestjs/common';
|
|
2
|
+
import { ConfigService } from '@nestjs/config';
|
|
3
|
+
import { RedisClientType } from 'redis';
|
|
4
|
+
export declare class RedisService implements OnModuleInit, OnModuleDestroy {
|
|
5
|
+
private config;
|
|
6
|
+
private readonly logger;
|
|
7
|
+
readonly client: RedisClientType;
|
|
8
|
+
constructor(config: ConfigService);
|
|
9
|
+
onModuleInit(): Promise<void>;
|
|
10
|
+
onModuleDestroy(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var RedisService_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.RedisService = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const config_1 = require("@nestjs/config");
|
|
16
|
+
const redis_1 = require("redis");
|
|
17
|
+
let RedisService = RedisService_1 = class RedisService {
|
|
18
|
+
config;
|
|
19
|
+
logger = new common_1.Logger(RedisService_1.name);
|
|
20
|
+
client;
|
|
21
|
+
constructor(config) {
|
|
22
|
+
this.config = config;
|
|
23
|
+
const url = this.config.get('REDIS_URL') || 'redis://localhost:6379';
|
|
24
|
+
this.client = (0, redis_1.createClient)({ url });
|
|
25
|
+
this.client.on('error', (err) => this.logger.error('Redis Client Error', err));
|
|
26
|
+
}
|
|
27
|
+
async onModuleInit() {
|
|
28
|
+
try {
|
|
29
|
+
await this.client.connect();
|
|
30
|
+
this.logger.log('✓ Redis connected successfully');
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
this.logger.error('Failed to connect to Redis', error);
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async onModuleDestroy() {
|
|
38
|
+
try {
|
|
39
|
+
await this.client.quit();
|
|
40
|
+
this.logger.log('Redis connection closed');
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
this.logger.error('Error closing Redis connection', error);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
exports.RedisService = RedisService;
|
|
48
|
+
exports.RedisService = RedisService = RedisService_1 = __decorate([
|
|
49
|
+
(0, common_1.Injectable)(),
|
|
50
|
+
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
51
|
+
], RedisService);
|
|
52
|
+
//# sourceMappingURL=redis.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.service.js","sourceRoot":"","sources":["../../../src/common/redis/redis.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAmF;AACnF,2CAA+C;AAC/C,iCAAsD;AAG/C,IAAM,YAAY,oBAAlB,MAAM,YAAY;IAIH;IAHH,MAAM,GAAG,IAAI,eAAM,CAAC,cAAY,CAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,CAAkB;IAEjC,YAAoB,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;QACvC,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAS,WAAW,CAAC,IAAI,wBAAwB,CAAC;QAC7E,IAAI,CAAC,MAAM,GAAG,IAAA,oBAAY,EAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QAEpC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAC9B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAC7C,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAC5B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;QACpD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;YACvD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACzB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;CACF,CAAA;AA/BY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;qCAKiB,sBAAa;GAJ9B,YAAY,CA+BxB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { OnModuleInit, OnModuleDestroy } from '@nestjs/common';
|
|
2
|
+
import { ConfigService } from '@nestjs/config';
|
|
3
|
+
import { Subject } from 'rxjs';
|
|
4
|
+
export declare class SqsConsumer implements OnModuleInit, OnModuleDestroy {
|
|
5
|
+
private readonly configService;
|
|
6
|
+
private readonly logger;
|
|
7
|
+
private sqsClient;
|
|
8
|
+
private isRunning;
|
|
9
|
+
private pollingInterval?;
|
|
10
|
+
readonly messageReceived$: Subject<any>;
|
|
11
|
+
constructor(configService: ConfigService);
|
|
12
|
+
onModuleInit(): void;
|
|
13
|
+
onModuleDestroy(): void;
|
|
14
|
+
startPolling(queueUrl: string, pollingInterval?: number): Promise<void>;
|
|
15
|
+
stopPolling(): void;
|
|
16
|
+
private pollMessages;
|
|
17
|
+
private handleMessage;
|
|
18
|
+
private processMessageContent;
|
|
19
|
+
private deleteMessage;
|
|
20
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var SqsConsumer_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.SqsConsumer = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const config_1 = require("@nestjs/config");
|
|
16
|
+
const client_sqs_1 = require("@aws-sdk/client-sqs");
|
|
17
|
+
const rxjs_1 = require("rxjs");
|
|
18
|
+
let SqsConsumer = SqsConsumer_1 = class SqsConsumer {
|
|
19
|
+
configService;
|
|
20
|
+
logger = new common_1.Logger(SqsConsumer_1.name);
|
|
21
|
+
sqsClient;
|
|
22
|
+
isRunning = false;
|
|
23
|
+
pollingInterval;
|
|
24
|
+
messageReceived$ = new rxjs_1.Subject();
|
|
25
|
+
constructor(configService) {
|
|
26
|
+
this.configService = configService;
|
|
27
|
+
const region = this.configService.get('AWS_REGION', 'us-east-1');
|
|
28
|
+
const accessKeyId = this.configService.get('AWS_ACCESS_KEY_ID', '');
|
|
29
|
+
const secretAccessKey = this.configService.get('AWS_SECRET_ACCESS_KEY', '');
|
|
30
|
+
this.sqsClient = new client_sqs_1.SQSClient({
|
|
31
|
+
region: region,
|
|
32
|
+
credentials: {
|
|
33
|
+
accessKeyId: accessKeyId,
|
|
34
|
+
secretAccessKey: secretAccessKey,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
onModuleInit() {
|
|
39
|
+
const enabled = this.configService.get('SQS_CONSUMER_ENABLED', false);
|
|
40
|
+
const queueUrl = this.configService.get('SQS_EXAMPLE_QUEUE_URL', '');
|
|
41
|
+
const queueInterval = this.configService.get('SQS_POLLING_INTERVAL', 1000);
|
|
42
|
+
if (enabled) {
|
|
43
|
+
this.startPolling(queueUrl, queueInterval);
|
|
44
|
+
this.logger.log('SQS Consumer inicializado');
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
this.logger.log('SQS Consumer deshabilitado por configuración');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
onModuleDestroy() {
|
|
51
|
+
this.logger.log('SQS Consumer destruido - limpiando recursos');
|
|
52
|
+
this.stopPolling();
|
|
53
|
+
}
|
|
54
|
+
async startPolling(queueUrl, pollingInterval = 1000) {
|
|
55
|
+
if (this.isRunning) {
|
|
56
|
+
this.logger.warn('El consumer ya está ejecutándose');
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (!queueUrl) {
|
|
60
|
+
this.logger.error('Queue URL no está configurada');
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this.isRunning = true;
|
|
64
|
+
this.logger.log(`Iniciando consumer para la cola: ${queueUrl}`);
|
|
65
|
+
this.logger.log(`Polling interval: ${pollingInterval}ms`);
|
|
66
|
+
this.pollingInterval = setInterval(() => {
|
|
67
|
+
this.pollMessages(queueUrl).catch((error) => {
|
|
68
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
69
|
+
this.logger.error(`Error en el polling: ${message}`);
|
|
70
|
+
});
|
|
71
|
+
}, pollingInterval);
|
|
72
|
+
}
|
|
73
|
+
stopPolling() {
|
|
74
|
+
if (this.pollingInterval) {
|
|
75
|
+
clearInterval(this.pollingInterval);
|
|
76
|
+
this.logger.log('Intervalo de polling detenido');
|
|
77
|
+
}
|
|
78
|
+
this.isRunning = false;
|
|
79
|
+
this.logger.log('Consumer detenido');
|
|
80
|
+
}
|
|
81
|
+
async pollMessages(queueUrl) {
|
|
82
|
+
const params = {
|
|
83
|
+
QueueUrl: queueUrl,
|
|
84
|
+
MaxNumberOfMessages: 10,
|
|
85
|
+
WaitTimeSeconds: 20,
|
|
86
|
+
};
|
|
87
|
+
if (queueUrl.includes('.fifo')) {
|
|
88
|
+
params.AttributeNames = ['All'];
|
|
89
|
+
}
|
|
90
|
+
const command = new client_sqs_1.ReceiveMessageCommand(params);
|
|
91
|
+
const response = await this.sqsClient.send(command);
|
|
92
|
+
if (response.Messages && response.Messages.length > 0) {
|
|
93
|
+
for (const message of response.Messages) {
|
|
94
|
+
try {
|
|
95
|
+
await this.handleMessage(message, queueUrl);
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
99
|
+
this.logger.error(`Error procesando mensaje: ${message}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async handleMessage(message, queueUrl) {
|
|
105
|
+
try {
|
|
106
|
+
this.logger.log(`Mensaje recibido: ${message.Body}`);
|
|
107
|
+
if (!message.Body) {
|
|
108
|
+
this.logger.warn('Mensaje sin Body, se omite el procesamiento');
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const body = JSON.parse(message.Body);
|
|
112
|
+
this.logger.log(`Contenido parseado:`, body);
|
|
113
|
+
await this.processMessageContent(body);
|
|
114
|
+
await this.deleteMessage(queueUrl, message.ReceiptHandle);
|
|
115
|
+
this.logger.log(`Mensaje eliminado de la cola`);
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
119
|
+
this.logger.error(`Error procesando mensaje: ${message}`);
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
async processMessageContent(body) {
|
|
124
|
+
this.logger.log(`Procesando contenido: ${JSON.stringify(body)}`);
|
|
125
|
+
this.messageReceived$.next(body);
|
|
126
|
+
}
|
|
127
|
+
async deleteMessage(queueUrl, receiptHandle) {
|
|
128
|
+
const command = new client_sqs_1.DeleteMessageCommand({
|
|
129
|
+
QueueUrl: queueUrl,
|
|
130
|
+
ReceiptHandle: receiptHandle,
|
|
131
|
+
});
|
|
132
|
+
await this.sqsClient.send(command);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
exports.SqsConsumer = SqsConsumer;
|
|
136
|
+
exports.SqsConsumer = SqsConsumer = SqsConsumer_1 = __decorate([
|
|
137
|
+
(0, common_1.Injectable)(),
|
|
138
|
+
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
139
|
+
], SqsConsumer);
|
|
140
|
+
//# sourceMappingURL=sqs.consumer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqs.consumer.js","sourceRoot":"","sources":["../../../src/common/sqs/sqs.consumer.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAmF;AACnF,2CAA+C;AAC/C,oDAA6F;AAC7F,+BAA+B;AAQxB,IAAM,WAAW,mBAAjB,MAAM,WAAW;IASO;IARZ,MAAM,GAAG,IAAI,eAAM,CAAC,aAAW,CAAC,IAAI,CAAC,CAAC;IAC/C,SAAS,CAAY;IACrB,SAAS,GAAG,KAAK,CAAC;IAClB,eAAe,CAAkB;IAGzB,gBAAgB,GAAG,IAAI,cAAO,EAAO,CAAC;IAEtD,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QACvD,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,YAAY,EAAE,WAAW,CAAC,CAAC;QACzE,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,mBAAmB,EAAE,EAAE,CAAC,CAAC;QAC5E,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,uBA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CAAC;QAClD,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,6BAA6B,OAAO,EAAE,CAAC,CAAC;YAE1D,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAOO,KAAK,CAAC,qBAAqB,CAAC,IAAS;QAC3C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,yBAAyB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEjE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAOO,KAAK,CAAC,aAAa,CAAC,QAAgB,EAAE,aAAqB;QACjE,MAAM,OAAO,GAAG,IAAI,iCAAoB,CAAC;YACvC,QAAQ,EAAE,QAAQ;YAClB,aAAa,EAAE,aAAa;SAC7B,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;CAGF,CAAA;AA1LY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;qCAUiC,sBAAa;GAT9C,WAAW,CA0LvB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SqsProducer } from './sqs.producer';
|
|
2
|
+
export declare class SqsController {
|
|
3
|
+
private readonly sqsProducer;
|
|
4
|
+
constructor(sqsProducer: SqsProducer);
|
|
5
|
+
sendEvent(data: any): Promise<{
|
|
6
|
+
success: boolean;
|
|
7
|
+
message: string;
|
|
8
|
+
}>;
|
|
9
|
+
sendNotification(body: {
|
|
10
|
+
title: string;
|
|
11
|
+
message: string;
|
|
12
|
+
userId?: string;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
success: boolean;
|
|
15
|
+
message: string;
|
|
16
|
+
}>;
|
|
17
|
+
sendTestMessage(): Promise<{
|
|
18
|
+
success: boolean;
|
|
19
|
+
message: string;
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SqsController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const sqs_producer_1 = require("./sqs.producer");
|
|
18
|
+
let SqsController = class SqsController {
|
|
19
|
+
sqsProducer;
|
|
20
|
+
constructor(sqsProducer) {
|
|
21
|
+
this.sqsProducer = sqsProducer;
|
|
22
|
+
}
|
|
23
|
+
async sendEvent(data) {
|
|
24
|
+
await this.sqsProducer.sendExampleEvent(data);
|
|
25
|
+
return {
|
|
26
|
+
success: true,
|
|
27
|
+
message: 'Evento enviado a SQS',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async sendNotification(body) {
|
|
31
|
+
await this.sqsProducer.sendNotification(body.title, body.message, body.userId);
|
|
32
|
+
return {
|
|
33
|
+
success: true,
|
|
34
|
+
message: 'Notificación enviada a SQS',
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
async sendTestMessage() {
|
|
38
|
+
await this.sqsProducer.sendTestMessage();
|
|
39
|
+
return {
|
|
40
|
+
success: true,
|
|
41
|
+
message: 'Mensaje de prueba enviado a SQS',
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
exports.SqsController = SqsController;
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, common_1.Post)('send-event'),
|
|
48
|
+
__param(0, (0, common_1.Body)()),
|
|
49
|
+
__metadata("design:type", Function),
|
|
50
|
+
__metadata("design:paramtypes", [Object]),
|
|
51
|
+
__metadata("design:returntype", Promise)
|
|
52
|
+
], SqsController.prototype, "sendEvent", null);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, common_1.Post)('send-notification'),
|
|
55
|
+
__param(0, (0, common_1.Body)()),
|
|
56
|
+
__metadata("design:type", Function),
|
|
57
|
+
__metadata("design:paramtypes", [Object]),
|
|
58
|
+
__metadata("design:returntype", Promise)
|
|
59
|
+
], SqsController.prototype, "sendNotification", null);
|
|
60
|
+
__decorate([
|
|
61
|
+
(0, common_1.Get)('test-message'),
|
|
62
|
+
__metadata("design:type", Function),
|
|
63
|
+
__metadata("design:paramtypes", []),
|
|
64
|
+
__metadata("design:returntype", Promise)
|
|
65
|
+
], SqsController.prototype, "sendTestMessage", null);
|
|
66
|
+
exports.SqsController = SqsController = __decorate([
|
|
67
|
+
(0, common_1.Controller)('sqs'),
|
|
68
|
+
__metadata("design:paramtypes", [sqs_producer_1.SqsProducer])
|
|
69
|
+
], SqsController);
|
|
70
|
+
//# sourceMappingURL=sqs.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqs.controller.js","sourceRoot":"","sources":["../../../src/common/sqs/sqs.controller.ts"],"names":[],"mappings":";;;;;;;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js/config';
|
|
3
|
+
import { SqsProducer } from './sqs.producer';
|
|
4
|
+
import { SqsConsumer } from './sqs.consumer';
|
|
5
|
+
export declare class SqsExampleService implements OnModuleInit, OnModuleDestroy {
|
|
6
|
+
private readonly sqsProducer;
|
|
7
|
+
private readonly sqsConsumer;
|
|
8
|
+
private readonly configService;
|
|
9
|
+
private readonly logger;
|
|
10
|
+
private subscriptions;
|
|
11
|
+
constructor(sqsProducer: SqsProducer, sqsConsumer: SqsConsumer, configService: ConfigService);
|
|
12
|
+
exampleSendProductCreationEvent(): Promise<void>;
|
|
13
|
+
exampleSendNotification(): Promise<void>;
|
|
14
|
+
exampleSendOrderEvent(): Promise<void>;
|
|
15
|
+
exampleSendBatchEvents(): Promise<void>;
|
|
16
|
+
onModuleInit(): void;
|
|
17
|
+
private startConsumerIfConfigured;
|
|
18
|
+
private setupEventSubscriptions;
|
|
19
|
+
private onAnyEventReceived;
|
|
20
|
+
private onProductEventReceived;
|
|
21
|
+
private onOrderEventReceived;
|
|
22
|
+
private onNotificationReceived;
|
|
23
|
+
private processNewOrder;
|
|
24
|
+
private updateOrderStatus;
|
|
25
|
+
private handleCancelledOrder;
|
|
26
|
+
onModuleDestroy(): void;
|
|
27
|
+
}
|