@nicollasfrazao/liguelead-log-service 1.0.0 → 1.1.0
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/README.md +29 -13
- package/dist/configs/log.storage.external.s3.config.d.ts.map +1 -1
- package/dist/configs/log.storage.external.s3.config.js +15 -2
- package/dist/configs/log.storage.external.s3.config.js.map +1 -1
- package/dist/helpers/arn.helper.d.ts +79 -0
- package/dist/helpers/arn.helper.d.ts.map +1 -0
- package/dist/helpers/arn.helper.js +107 -0
- package/dist/helpers/arn.helper.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces/log.storage.external.s3.service.config.interface.d.ts +5 -0
- package/dist/interfaces/log.storage.external.s3.service.config.interface.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ npm install @ligue-lead-tech/log-service-nodejs
|
|
|
14
14
|
|
|
15
15
|
```typescript
|
|
16
16
|
import express from 'express';
|
|
17
|
-
import { LogService,
|
|
17
|
+
import { LogService, logMiddleware } from '@ligue-lead-tech/log-service-nodejs';
|
|
18
18
|
|
|
19
19
|
const app = express();
|
|
20
20
|
|
|
@@ -25,7 +25,7 @@ process.env.LOG_DESTINATION = 'both'; // 'console', 'storage', ou 'both'
|
|
|
25
25
|
process.env.NODE_ENV = 'development';
|
|
26
26
|
|
|
27
27
|
// Adicione o middleware de logging (obrigatório para correlation IDs)
|
|
28
|
-
app.use(
|
|
28
|
+
app.use(logMiddleware);
|
|
29
29
|
|
|
30
30
|
// Suas rotas
|
|
31
31
|
app.get('/api/users', (req, res) => {
|
|
@@ -49,6 +49,7 @@ app.listen(3000, () => {
|
|
|
49
49
|
|
|
50
50
|
### 2. Configuração com S3 via Kinesis Firehose
|
|
51
51
|
|
|
52
|
+
#### Usando Nome do Stream (método tradicional)
|
|
52
53
|
```typescript
|
|
53
54
|
// Configuração para produção com S3
|
|
54
55
|
process.env.LOG_USE_S3_STORAGE = 'true';
|
|
@@ -61,6 +62,16 @@ process.env.LOG_AWS_ACCESS_KEY_ID = 'test';
|
|
|
61
62
|
process.env.LOG_AWS_SECRET_ACCESS_KEY = 'test';
|
|
62
63
|
```
|
|
63
64
|
|
|
65
|
+
#### Usando ARN do Firehose (recomendado)
|
|
66
|
+
```typescript
|
|
67
|
+
// Configuração com ARN - extrai automaticamente região e nome do stream
|
|
68
|
+
process.env.LOG_USE_S3_STORAGE = 'true';
|
|
69
|
+
process.env.LOG_FIREHOSE_STREAM_ARN = 'arn:aws:firehose:us-east-1:123456789012:deliverystream/my-app-logs-firehose';
|
|
70
|
+
|
|
71
|
+
// As variáveis LOG_AWS_REGION e LOG_FIREHOSE_STREAM_NAME são opcionais quando usar ARN
|
|
72
|
+
// A região e nome do stream são extraídos automaticamente do ARN
|
|
73
|
+
```
|
|
74
|
+
|
|
64
75
|
### 3. Logging Manual
|
|
65
76
|
|
|
66
77
|
```typescript
|
|
@@ -125,7 +136,7 @@ Os logs são organizados por ambiente e salvos via **Kinesis Firehose** para S3,
|
|
|
125
136
|
|
|
126
137
|
### Armazenamento S3 (via Kinesis Firehose)
|
|
127
138
|
```
|
|
128
|
-
|
|
139
|
+
my-app-logs/
|
|
129
140
|
├── logs/
|
|
130
141
|
│ ├── development/
|
|
131
142
|
│ │ └── 2025-10-27-combined.log.gz # Logs comprimidos pelo Firehose
|
|
@@ -183,7 +194,7 @@ Quando `LOG_USE_S3_STORAGE=true`, os logs são enviados para **Kinesis Firehose*
|
|
|
183
194
|
|
|
184
195
|
Exemplo de estrutura no S3 via Firehose:
|
|
185
196
|
```
|
|
186
|
-
|
|
197
|
+
my-app-logs/
|
|
187
198
|
├── logs/
|
|
188
199
|
│ ├── 2025/10/27/14/
|
|
189
200
|
│ │ ├── firehose_output-1-2025-10-27-14-01-01-uuid.gz
|
|
@@ -208,11 +219,16 @@ NODE_ENV=development # development|production|homologation|tes
|
|
|
208
219
|
|
|
209
220
|
# S3 via Kinesis Firehose
|
|
210
221
|
LOG_USE_S3_STORAGE=true # Ativa envio para S3 via Firehose
|
|
222
|
+
|
|
223
|
+
# Opção 1: Usar ARN do Firehose (recomendado)
|
|
224
|
+
LOG_FIREHOSE_STREAM_ARN=arn:aws:firehose:us-east-1:123456789012:deliverystream/my-app-logs-firehose
|
|
225
|
+
|
|
226
|
+
# Opção 2: Usar nome e região separadamente
|
|
211
227
|
LOG_FIREHOSE_STREAM_NAME=my-app-logs # Nome do stream Kinesis Firehose
|
|
228
|
+
LOG_AWS_REGION=us-east-1 # Região AWS (não necessária se usar ARN)
|
|
212
229
|
|
|
213
230
|
# AWS (apenas para desenvolvimento/LocalStack)
|
|
214
231
|
LOG_AWS_ENDPOINT=http://localhost:4566 # Endpoint AWS (LocalStack)
|
|
215
|
-
LOG_AWS_REGION=us-east-1 # Região AWS
|
|
216
232
|
LOG_AWS_ACCESS_KEY_ID=test # Access Key (dev only)
|
|
217
233
|
LOG_AWS_SECRET_ACCESS_KEY=test # Secret Key (dev only)
|
|
218
234
|
|
|
@@ -334,7 +350,7 @@ LOG_DESTINATION=storage
|
|
|
334
350
|
LOG_USE_S3_STORAGE=true
|
|
335
351
|
|
|
336
352
|
# Nome do Kinesis Firehose stream
|
|
337
|
-
LOG_FIREHOSE_STREAM_NAME=
|
|
353
|
+
LOG_FIREHOSE_STREAM_NAME=my-app-logs-firehose
|
|
338
354
|
|
|
339
355
|
# Região AWS
|
|
340
356
|
LOG_AWS_REGION=us-east-1
|
|
@@ -371,7 +387,7 @@ LOG_USE=true
|
|
|
371
387
|
LOG_LEVEL=debug
|
|
372
388
|
LOG_DESTINATION=both
|
|
373
389
|
LOG_USE_S3_STORAGE=true
|
|
374
|
-
LOG_FIREHOSE_STREAM_NAME=
|
|
390
|
+
LOG_FIREHOSE_STREAM_NAME=my-app-logs-firehose
|
|
375
391
|
LOG_AWS_ENDPOINT=http://localhost:4566
|
|
376
392
|
LOG_AWS_ACCESS_KEY_ID=test
|
|
377
393
|
LOG_AWS_SECRET_ACCESS_KEY=test
|
|
@@ -384,7 +400,7 @@ LOG_USE=true
|
|
|
384
400
|
LOG_LEVEL=info
|
|
385
401
|
LOG_DESTINATION=storage
|
|
386
402
|
LOG_USE_S3_STORAGE=true
|
|
387
|
-
LOG_FIREHOSE_STREAM_NAME=
|
|
403
|
+
LOG_FIREHOSE_STREAM_NAME=my-app-logs-firehose-hml
|
|
388
404
|
# AWS credentials via IAM role ou environment variables
|
|
389
405
|
```
|
|
390
406
|
|
|
@@ -395,7 +411,7 @@ LOG_USE=true
|
|
|
395
411
|
LOG_LEVEL=warn
|
|
396
412
|
LOG_DESTINATION=storage
|
|
397
413
|
LOG_USE_S3_STORAGE=true
|
|
398
|
-
LOG_FIREHOSE_STREAM_NAME=
|
|
414
|
+
LOG_FIREHOSE_STREAM_NAME=my-app-logs-firehose-prod
|
|
399
415
|
LOG_INCLUDE_REQUEST_BODY=false
|
|
400
416
|
LOG_INCLUDE_RESPONSE_BODY=false
|
|
401
417
|
LOG_MAX_BODY_SIZE=1000
|
|
@@ -515,9 +531,9 @@ scripts/ # Scripts utilitários
|
|
|
515
531
|
O middleware de logging é aplicado automaticamente a todas as rotas:
|
|
516
532
|
|
|
517
533
|
```typescript
|
|
518
|
-
import {
|
|
534
|
+
import { logMiddleware } from './src/middlewares/log.middleware';
|
|
519
535
|
|
|
520
|
-
app.use(
|
|
536
|
+
app.use(logMiddleware);
|
|
521
537
|
```
|
|
522
538
|
|
|
523
539
|
### 5. Logging Manual
|
|
@@ -622,13 +638,13 @@ Para integrar o serviço em sua aplicação Express:
|
|
|
622
638
|
|
|
623
639
|
```typescript
|
|
624
640
|
import express from 'express';
|
|
625
|
-
import {
|
|
641
|
+
import { logMiddleware } from './src/middlewares/log.middleware';
|
|
626
642
|
import { LogService } from './src/services/log.service';
|
|
627
643
|
|
|
628
644
|
const app = express();
|
|
629
645
|
|
|
630
646
|
// Aplicar middleware de logging
|
|
631
|
-
app.use(
|
|
647
|
+
app.use(logMiddleware);
|
|
632
648
|
|
|
633
649
|
// Exemplo de uso manual
|
|
634
650
|
app.get('/health', (req, res) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.storage.external.s3.config.d.ts","sourceRoot":"","sources":["../../src/configs/log.storage.external.s3.config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"log.storage.external.s3.config.d.ts","sourceRoot":"","sources":["../../src/configs/log.storage.external.s3.config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0CAA0C,EAAE,MAAM,gEAAgE,CAAC;AAM5H;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,QAAO,0CAmChD,CAAA"}
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getLogStorageExternalS3Config = void 0;
|
|
4
|
+
const log_error_1 = require("../errors/log.error");
|
|
5
|
+
const arn_helper_1 = require("../helpers/arn.helper");
|
|
4
6
|
/**
|
|
5
7
|
* Get Log Storage External S3 Configuration
|
|
6
8
|
*
|
|
7
9
|
* @returns {LogStorageExternalS3ServiceConfigInterface} Log Storage External S3 Configuration
|
|
8
10
|
*/
|
|
9
11
|
const getLogStorageExternalS3Config = () => {
|
|
12
|
+
const firehoseArn = process.env.LOG_FIREHOSE_STREAM_ARN;
|
|
13
|
+
let firehoseStreamName = process.env.LOG_FIREHOSE_STREAM_NAME || 'log-service-firehose';
|
|
14
|
+
let region = process.env.LOG_AWS_REGION || 'us-east-1';
|
|
15
|
+
if (firehoseArn) {
|
|
16
|
+
if (!arn_helper_1.ArnHelper.isFirehoseDeliveryStreamARN(firehoseArn)) {
|
|
17
|
+
throw new log_error_1.LogError(`Invalid Kinesis Firehose delivery stream ARN: ${firehoseArn}`);
|
|
18
|
+
}
|
|
19
|
+
firehoseStreamName = arn_helper_1.ArnHelper.getFirehoseStreamNameFromARN(firehoseArn);
|
|
20
|
+
region = arn_helper_1.ArnHelper.getRegionFromARN(firehoseArn);
|
|
21
|
+
}
|
|
10
22
|
let config = {
|
|
11
|
-
firehoseStreamName
|
|
12
|
-
|
|
23
|
+
firehoseStreamName,
|
|
24
|
+
firehoseStreamArn: firehoseArn,
|
|
25
|
+
region,
|
|
13
26
|
version: 'latest',
|
|
14
27
|
};
|
|
15
28
|
if (process.env.LOG_AWS_ACCESS_KEY_ID
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.storage.external.s3.config.js","sourceRoot":"","sources":["../../src/configs/log.storage.external.s3.config.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"log.storage.external.s3.config.js","sourceRoot":"","sources":["../../src/configs/log.storage.external.s3.config.ts"],"names":[],"mappings":";;;AAAA,mDAA+C;AAE/C,sDAG+B;AAE/B;;;;GAIG;AACI,MAAM,6BAA6B,GAAG,GAA+C,EAAE;IAE5F,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC;IACxD,IAAI,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,sBAAsB,CAAC;IACxF,IAAI,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,WAAW,CAAC;IAEvD,IAAI,WAAW,EAAE,CAAC;QAChB,IAAI,CAAC,sBAAS,CAAC,2BAA2B,CAAC,WAAW,CAAC,EAAE,CAAC;YACxD,MAAM,IAAI,oBAAQ,CAAC,iDAAiD,WAAW,EAAE,CAAC,CAAC;QACrF,CAAC;QAED,kBAAkB,GAAG,sBAAS,CAAC,4BAA4B,CAAC,WAAW,CAAC,CAAC;QACzE,MAAM,GAAG,sBAAS,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,MAAM,GAA+C;QACvD,kBAAkB;QAClB,iBAAiB,EAAE,WAAW;QAC9B,MAAM;QACN,OAAO,EAAE,QAAQ;KAClB,CAAC;IAEF,IACE,OAAO,CAAC,GAAG,CAAC,qBAAqB;WAC9B,OAAO,CAAC,GAAG,CAAC,yBAAyB,EACxC,CAAC;QACD,MAAM,GAAG;YACP,GAAG,MAAM;YACT,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,uBAAuB;YACjE,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;YAC9C,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB;SACvD,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAA;AAnCY,QAAA,6BAA6B,iCAmCzC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for working with AWS ARNs
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Interface ArnInterface
|
|
6
|
+
*
|
|
7
|
+
* Represents the components of a parsed AWS ARN.
|
|
8
|
+
*
|
|
9
|
+
* @property {string} service - The AWS service (e.g., 'firehose')
|
|
10
|
+
* @property {string} region - The AWS region (e.g., 'us-east-1')
|
|
11
|
+
* @property {string} accountId - The AWS account ID
|
|
12
|
+
* @property {string} resourceType - The type of resource (e.g., 'deliverystream')
|
|
13
|
+
* @property {string} resourceName - The name of the resource
|
|
14
|
+
* @property {string} fullArn - The full ARN string
|
|
15
|
+
*/
|
|
16
|
+
export interface ArnInterface {
|
|
17
|
+
service: string;
|
|
18
|
+
region: string;
|
|
19
|
+
accountId: string;
|
|
20
|
+
resourceType: string;
|
|
21
|
+
resourceName: string;
|
|
22
|
+
fullArn: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Class ArnHelper
|
|
26
|
+
*
|
|
27
|
+
* Provides utility functions for parsing and validating AWS ARNs.
|
|
28
|
+
*/
|
|
29
|
+
export declare class ArnHelper {
|
|
30
|
+
/**
|
|
31
|
+
* Parses an AWS ARN and extracts its components
|
|
32
|
+
*
|
|
33
|
+
* @param {string} arn - The AWS ARN to parse
|
|
34
|
+
*
|
|
35
|
+
* @throws {LogError} if ARN format is invalid
|
|
36
|
+
*
|
|
37
|
+
* @returns {ArnInterface} Parsed ARN components
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* const parsed = parseARN('arn:aws:firehose:us-east-1:123456789012:deliverystream/my-app-logs-firehose');
|
|
41
|
+
* // Returns:
|
|
42
|
+
* // {
|
|
43
|
+
* // service: 'firehose',
|
|
44
|
+
* // region: 'us-east-1',
|
|
45
|
+
* // accountId: '123456789012',
|
|
46
|
+
* // resourceType: 'deliverystream',
|
|
47
|
+
* // resourceName: 'my-app-logs-firehose',
|
|
48
|
+
* // fullArn: 'arn:aws:firehose:us-east-1:123456789012:deliverystream/my-app-logs-firehose'
|
|
49
|
+
* // }
|
|
50
|
+
*/
|
|
51
|
+
private static parseARN;
|
|
52
|
+
/**
|
|
53
|
+
* Validates if an ARN is for a Kinesis Firehose delivery stream
|
|
54
|
+
*
|
|
55
|
+
* @param {string} arn - The AWS ARN to validate
|
|
56
|
+
*
|
|
57
|
+
* @returns {boolean} true if it's a valid Firehose delivery stream ARN
|
|
58
|
+
*/
|
|
59
|
+
static isFirehoseDeliveryStreamARN(arn: string): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Extracts Firehose delivery stream name from ARN
|
|
62
|
+
*
|
|
63
|
+
* @param {string} arn - The Kinesis Firehose ARN
|
|
64
|
+
*
|
|
65
|
+
* @throws {Error} if ARN is not a valid Firehose delivery stream ARN
|
|
66
|
+
*
|
|
67
|
+
* @returns {string} The delivery stream name
|
|
68
|
+
*/
|
|
69
|
+
static getFirehoseStreamNameFromARN(arn: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* Extracts AWS region from ARN
|
|
72
|
+
*
|
|
73
|
+
* @param {string} arn - The AWS ARN
|
|
74
|
+
*
|
|
75
|
+
* @returns {string} The AWS region
|
|
76
|
+
*/
|
|
77
|
+
static getRegionFromARN(arn: string): string;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=arn.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arn.helper.d.ts","sourceRoot":"","sources":["../../src/helpers/arn.helper.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,qBAAa,SAAS;IACpB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ;IA2CvB;;;;;;OAMG;WACW,2BAA2B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAY/D;;;;;;;;OAQG;WACW,4BAA4B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAW/D;;;;;;OAMG;WACW,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAMpD"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Utilities for working with AWS ARNs
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ArnHelper = void 0;
|
|
7
|
+
const log_error_1 = require("../errors/log.error");
|
|
8
|
+
/**
|
|
9
|
+
* Class ArnHelper
|
|
10
|
+
*
|
|
11
|
+
* Provides utility functions for parsing and validating AWS ARNs.
|
|
12
|
+
*/
|
|
13
|
+
class ArnHelper {
|
|
14
|
+
/**
|
|
15
|
+
* Parses an AWS ARN and extracts its components
|
|
16
|
+
*
|
|
17
|
+
* @param {string} arn - The AWS ARN to parse
|
|
18
|
+
*
|
|
19
|
+
* @throws {LogError} if ARN format is invalid
|
|
20
|
+
*
|
|
21
|
+
* @returns {ArnInterface} Parsed ARN components
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const parsed = parseARN('arn:aws:firehose:us-east-1:123456789012:deliverystream/my-app-logs-firehose');
|
|
25
|
+
* // Returns:
|
|
26
|
+
* // {
|
|
27
|
+
* // service: 'firehose',
|
|
28
|
+
* // region: 'us-east-1',
|
|
29
|
+
* // accountId: '123456789012',
|
|
30
|
+
* // resourceType: 'deliverystream',
|
|
31
|
+
* // resourceName: 'my-app-logs-firehose',
|
|
32
|
+
* // fullArn: 'arn:aws:firehose:us-east-1:123456789012:deliverystream/my-app-logs-firehose'
|
|
33
|
+
* // }
|
|
34
|
+
*/
|
|
35
|
+
static parseARN(arn) {
|
|
36
|
+
if (!arn
|
|
37
|
+
|| typeof arn !== 'string') {
|
|
38
|
+
throw new log_error_1.LogError('ARN must be a non-empty string');
|
|
39
|
+
}
|
|
40
|
+
const arnRegex = /^arn:aws:([^:]+):([^:]*):([^:]*):(.+)$/;
|
|
41
|
+
const match = arn.match(arnRegex);
|
|
42
|
+
if (!match) {
|
|
43
|
+
throw new log_error_1.LogError(`Invalid ARN format: ${arn}`);
|
|
44
|
+
}
|
|
45
|
+
const [, service, region, accountId, resource] = match;
|
|
46
|
+
const resourceParts = resource.split(/[/:]/);
|
|
47
|
+
if (resourceParts.length < 2) {
|
|
48
|
+
throw new log_error_1.LogError(`Invalid resource format in ARN: ${arn}`);
|
|
49
|
+
}
|
|
50
|
+
const resourceType = resourceParts[0];
|
|
51
|
+
const resourceName = resourceParts.slice(1).join('/'); // Handle cases with multiple slashes
|
|
52
|
+
return {
|
|
53
|
+
service,
|
|
54
|
+
region,
|
|
55
|
+
accountId,
|
|
56
|
+
resourceType,
|
|
57
|
+
resourceName,
|
|
58
|
+
fullArn: arn
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Validates if an ARN is for a Kinesis Firehose delivery stream
|
|
63
|
+
*
|
|
64
|
+
* @param {string} arn - The AWS ARN to validate
|
|
65
|
+
*
|
|
66
|
+
* @returns {boolean} true if it's a valid Firehose delivery stream ARN
|
|
67
|
+
*/
|
|
68
|
+
static isFirehoseDeliveryStreamARN(arn) {
|
|
69
|
+
try {
|
|
70
|
+
const parsed = this.parseARN(arn);
|
|
71
|
+
return parsed.service === 'firehose'
|
|
72
|
+
&& parsed.resourceType === 'deliverystream';
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Extracts Firehose delivery stream name from ARN
|
|
80
|
+
*
|
|
81
|
+
* @param {string} arn - The Kinesis Firehose ARN
|
|
82
|
+
*
|
|
83
|
+
* @throws {Error} if ARN is not a valid Firehose delivery stream ARN
|
|
84
|
+
*
|
|
85
|
+
* @returns {string} The delivery stream name
|
|
86
|
+
*/
|
|
87
|
+
static getFirehoseStreamNameFromARN(arn) {
|
|
88
|
+
if (!this.isFirehoseDeliveryStreamARN(arn)) {
|
|
89
|
+
throw new log_error_1.LogError(`ARN is not a valid Kinesis Firehose delivery stream: ${arn}`);
|
|
90
|
+
}
|
|
91
|
+
const parsed = this.parseARN(arn);
|
|
92
|
+
return parsed.resourceName;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Extracts AWS region from ARN
|
|
96
|
+
*
|
|
97
|
+
* @param {string} arn - The AWS ARN
|
|
98
|
+
*
|
|
99
|
+
* @returns {string} The AWS region
|
|
100
|
+
*/
|
|
101
|
+
static getRegionFromARN(arn) {
|
|
102
|
+
const parsed = this.parseARN(arn);
|
|
103
|
+
return parsed.region;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.ArnHelper = ArnHelper;
|
|
107
|
+
//# sourceMappingURL=arn.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arn.helper.js","sourceRoot":"","sources":["../../src/helpers/arn.helper.ts"],"names":[],"m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,KAAK,UAAU;mBAC/B,MAAM,CAAC,YAAY,KAAK,gBAAgB,CAAC;QAChD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,4BAA4B,CAAC,GAAW;QAEpD,IAAI,CAAC,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,oBAAQ,CAAC,wDAAwD,GAAG,EAAE,CAAC,CAAC;QACpF,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAElC,OAAO,MAAM,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,gBAAgB,CAAC,GAAW;QAExC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAElC,OAAO,MAAM,CAAC,MAAM,CAAC;IACvB,CAAC;CACF;AArHD,8BAqHC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -19,4 +19,6 @@ export { LogStorageLocalService } from './services/log.storage.local.service';
|
|
|
19
19
|
export { LogStorageExternalS3Service } from './services/log.storage.external.s3.service';
|
|
20
20
|
export { LogStorageExternalService } from './services/log.storage.external.service';
|
|
21
21
|
export type { LogStorageBaseServiceInterface } from './interfaces/log.storage.base.service.interface';
|
|
22
|
+
export { ArnHelper } from './helpers/arn.helper';
|
|
23
|
+
export type { ArnInterface } from './helpers/arn.helper';
|
|
22
24
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGpD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAG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,MAAM,0CAA0C,CAAC;AAGzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAGpF,YAAY,EAAE,8BAA8B,EAAE,MAAM,iDAAiD,CAAC;AAGtG,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* (local files + S3 via Kinesis Firehose) and comprehensive request tracking.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.LogStorageExternalService = exports.LogStorageExternalS3Service = exports.LogStorageLocalService = exports.LogStorageBaseService = exports.LogStorageService = exports.getLogStorageExternalS3Config = exports.getLogServiceConfig = exports.LogError = exports.logMiddleware = exports.LogService = void 0;
|
|
9
|
+
exports.ArnHelper = exports.LogStorageExternalService = exports.LogStorageExternalS3Service = exports.LogStorageLocalService = exports.LogStorageBaseService = exports.LogStorageService = exports.getLogStorageExternalS3Config = exports.getLogServiceConfig = exports.LogError = exports.logMiddleware = exports.LogService = void 0;
|
|
10
10
|
// Main service exports
|
|
11
11
|
var log_service_1 = require("./services/log.service");
|
|
12
12
|
Object.defineProperty(exports, "LogService", { enumerable: true, get: function () { return log_service_1.LogService; } });
|
|
@@ -32,4 +32,7 @@ var log_storage_external_s3_service_1 = require("./services/log.storage.external
|
|
|
32
32
|
Object.defineProperty(exports, "LogStorageExternalS3Service", { enumerable: true, get: function () { return log_storage_external_s3_service_1.LogStorageExternalS3Service; } });
|
|
33
33
|
var log_storage_external_service_1 = require("./services/log.storage.external.service");
|
|
34
34
|
Object.defineProperty(exports, "LogStorageExternalService", { enumerable: true, get: function () { return log_storage_external_service_1.LogStorageExternalService; } });
|
|
35
|
+
// ARN utilities export
|
|
36
|
+
var arn_helper_1 = require("./helpers/arn.helper");
|
|
37
|
+
Object.defineProperty(exports, "ArnHelper", { enumerable: true, get: function () { return arn_helper_1.ArnHelper; } });
|
|
35
38
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,uBAAuB;AACvB,sDAAoD;AAA3C,yGAAA,UAAU,OAAA;AAEnB,uBAAuB;AACvB,+DAA6D;AAApD,+GAAA,aAAa,OAAA;AAEtB,yBAAyB;AACzB,gDAA8C;AAArC,qGAAA,QAAQ,OAAA;AAUjB,wBAAwB;AACxB,mEAAmE;AAA1D,yHAAA,mBAAmB,OAAA;AAC5B,2FAAyF;AAAhF,+IAAA,6BAA6B,OAAA;AAEtC,+CAA+C;AAC/C,sEAAmE;AAA1D,wHAAA,iBAAiB,OAAA;AAC1B,gFAA4E;AAAnE,iIAAA,qBAAqB,OAAA;AAC9B,kFAA8E;AAArE,mIAAA,sBAAsB,OAAA;AAC/B,8FAAyF;AAAhF,8IAAA,2BAA2B,OAAA;AACpC,wFAAoF;AAA3E,yIAAA,yBAAyB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,uBAAuB;AACvB,sDAAoD;AAA3C,yGAAA,UAAU,OAAA;AAEnB,uBAAuB;AACvB,+DAA6D;AAApD,+GAAA,aAAa,OAAA;AAEtB,yBAAyB;AACzB,gDAA8C;AAArC,qGAAA,QAAQ,OAAA;AAUjB,wBAAwB;AACxB,mEAAmE;AAA1D,yHAAA,mBAAmB,OAAA;AAC5B,2FAAyF;AAAhF,+IAAA,6BAA6B,OAAA;AAEtC,+CAA+C;AAC/C,sEAAmE;AAA1D,wHAAA,iBAAiB,OAAA;AAC1B,gFAA4E;AAAnE,iIAAA,qBAAqB,OAAA;AAC9B,kFAA8E;AAArE,mIAAA,sBAAsB,OAAA;AAC/B,8FAAyF;AAAhF,8IAAA,2BAA2B,OAAA;AACpC,wFAAoF;AAA3E,yIAAA,yBAAyB,OAAA;AAKlC,uBAAuB;AACvB,mDAAiD;AAAxC,uGAAA,SAAS,OAAA"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @property {string} region - AWS region for S3/Firebase
|
|
7
7
|
* @property {string} version - AWS SDK version
|
|
8
8
|
* @property {string} firehoseStreamName - Kinesis Firehose stream name
|
|
9
|
+
* @property {string} firehoseStreamArn - Kinesis Firehose stream ARN (alternative to firehoseStreamName)
|
|
9
10
|
* @property {string} endpoint - Custom S3 endpoint (optional)
|
|
10
11
|
* @property {string} accessKeyId - AWS access key ID (optional)
|
|
11
12
|
* @property {string} secretAccessKey - AWS secret access key (optional)
|
|
@@ -23,6 +24,10 @@ export interface LogStorageExternalS3ServiceConfigInterface {
|
|
|
23
24
|
* @var {string}
|
|
24
25
|
*/
|
|
25
26
|
firehoseStreamName: string;
|
|
27
|
+
/**
|
|
28
|
+
* @var {string} - Kinesis Firehose stream ARN (optional, alternative to firehoseStreamName)
|
|
29
|
+
*/
|
|
30
|
+
firehoseStreamArn?: string;
|
|
26
31
|
/**
|
|
27
32
|
* @var {string}
|
|
28
33
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.storage.external.s3.service.config.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/log.storage.external.s3.service.config.interface.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"log.storage.external.s3.service.config.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/log.storage.external.s3.service.config.interface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,0CAA0C;IAEzD;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nicollasfrazao/liguelead-log-service",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A standalone logging service for Express applications with multi-destination storage (local files + S3 via Kinesis Firehose) and comprehensive request tracking using strategy pattern.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|