bugg-lens-nestjs 0.1.0 → 0.1.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/dist/bugg-lens.d.ts +8 -4
- package/dist/bugg-lens.d.ts.map +1 -1
- package/dist/bugg-lens.interceptor.d.ts +6 -0
- package/dist/bugg-lens.interceptor.d.ts.map +1 -0
- package/dist/bugg-lens.interceptor.js +20 -0
- package/dist/bugg-lens.interceptor.js.map +1 -0
- package/dist/bugg-lens.js +66 -16
- package/dist/bugg-lens.js.map +1 -1
- package/dist/bugg-lens.module.d.ts +5 -11
- package/dist/bugg-lens.module.d.ts.map +1 -1
- package/dist/bugg-lens.module.js +18 -27
- package/dist/bugg-lens.module.js.map +1 -1
- package/dist/bugg-lens.util.d.ts +0 -13
- package/dist/bugg-lens.util.d.ts.map +1 -1
- package/dist/bugg-lens.util.js +1 -1
- package/dist/bugg-lens.util.js.map +1 -1
- package/dist/bugg-lens.worker.d.ts.map +1 -1
- package/dist/bugg-lens.worker.js +0 -8
- package/dist/bugg-lens.worker.js.map +1 -1
- package/package.json +50 -48
package/dist/bugg-lens.d.ts
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
+
import { ExecutionContext } from '@nestjs/common';
|
|
1
2
|
export interface BuggLensOptions {
|
|
2
3
|
dsn: string;
|
|
3
4
|
apiKey?: string;
|
|
4
5
|
apiKeyHeader?: string;
|
|
5
6
|
headers?: Record<string, string>;
|
|
6
7
|
timeoutMs?: number;
|
|
8
|
+
ignoreErrors?: any[];
|
|
9
|
+
maxRateLimit?: 100 | 200 | 300 | 400 | 500;
|
|
7
10
|
}
|
|
8
11
|
export declare class BuggLens {
|
|
9
12
|
private readonly options;
|
|
10
13
|
private readonly http;
|
|
14
|
+
private errorCount;
|
|
15
|
+
private windowResetTime;
|
|
11
16
|
constructor(options: BuggLensOptions);
|
|
12
|
-
connect(): Promise<void>;
|
|
13
|
-
disconnect(): Promise<void>;
|
|
14
17
|
private buildHeaders;
|
|
15
|
-
capture(error: Error): void;
|
|
16
|
-
|
|
18
|
+
capture(error: Error, context: ExecutionContext): void;
|
|
19
|
+
private isRateLimited;
|
|
20
|
+
private captureAsync;
|
|
17
21
|
private extractErrorMeta;
|
|
18
22
|
private sendSourceContext;
|
|
19
23
|
private extractFrame;
|
package/dist/bugg-lens.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bugg-lens.d.ts","sourceRoot":"","sources":["../bugg-lens.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bugg-lens.d.ts","sourceRoot":"","sources":["../bugg-lens.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAsB,MAAM,gBAAgB,CAAC;AAGtE,MAAM,WAAW,eAAe;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,GAAG,EAAE,CAAA;IACpB,YAAY,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;CAC7C;AASD,qBACa,QAAQ;IAMc,OAAO,CAAC,QAAQ,CAAC,OAAO;IALvD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAgB;IACrC,OAAO,CAAC,UAAU,CAAI;IACtB,OAAO,CAAC,eAAe,CAAsB;gBAGG,OAAO,EAAE,eAAe;IASxE,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAatD,OAAO,CAAC,aAAa;YAsBP,YAAY;IAkC1B,OAAO,CAAC,gBAAgB;YAYV,iBAAiB;IAa/B,OAAO,CAAC,YAAY;CAevB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CallHandler, ExecutionContext, NestInterceptor } from "@nestjs/common";
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
export declare class BuggLensInterceptor implements NestInterceptor {
|
|
4
|
+
intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=bugg-lens.interceptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bugg-lens.interceptor.d.ts","sourceRoot":"","sources":["../bugg-lens.interceptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAc,UAAU,EAAc,MAAM,MAAM,CAAC;AAE1D,qBAAa,mBAAoB,YAAW,eAAe;IACvD,SAAS,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,GAAG,UAAU,CAAC,GAAG,CAAC;CAoB3E"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuggLensInterceptor = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
class BuggLensInterceptor {
|
|
6
|
+
intercept(context, next) {
|
|
7
|
+
const type = context.getType();
|
|
8
|
+
if (type === 'http') {
|
|
9
|
+
const http = context.switchToHttp();
|
|
10
|
+
const req = http.getRequest();
|
|
11
|
+
return next.handle().pipe((0, rxjs_1.catchError)((error) => {
|
|
12
|
+
return (0, rxjs_1.throwError)(() => error);
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
return next
|
|
16
|
+
.handle();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.BuggLensInterceptor = BuggLensInterceptor;
|
|
20
|
+
//# sourceMappingURL=bugg-lens.interceptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bugg-lens.interceptor.js","sourceRoot":"","sources":["../bugg-lens.interceptor.ts"],"names":[],"mappings":";;;AACA,+BAA0D;AAE1D,MAAa,mBAAmB;IAC5B,SAAS,CAAC,OAAyB,EAAE,IAAiB;QAElD,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAA;QAE9B,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YAElB,MAAM,IAAI,GAAG,OAAO,CAAC,YAAY,EAAE,CAAA;YAEnC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,EAAE,CAAA;YAE7B,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CACrB,IAAA,iBAAU,EAAC,CAAC,KAAK,EAAE,EAAE;gBACjB,OAAO,IAAA,iBAAU,EAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;YACnC,CAAC,CAAC,CACL,CAAC;QACN,CAAC;QAED,OAAO,IAAI;aACN,MAAM,EAAE,CAAA;IACjB,CAAC;CACJ;AArBD,kDAqBC"}
|
package/dist/bugg-lens.js
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
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
|
+
};
|
|
2
14
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
15
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
16
|
};
|
|
@@ -6,19 +18,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
18
|
exports.BuggLens = void 0;
|
|
7
19
|
const axios_1 = __importDefault(require("axios"));
|
|
8
20
|
const bugg_lens_util_1 = require("./bugg-lens.util");
|
|
9
|
-
|
|
21
|
+
const common_1 = require("@nestjs/common");
|
|
22
|
+
const bugg_lens_module_1 = require("./bugg-lens.module");
|
|
23
|
+
let BuggLens = class BuggLens {
|
|
10
24
|
constructor(options) {
|
|
11
25
|
this.options = options;
|
|
26
|
+
this.errorCount = 0;
|
|
27
|
+
this.windowResetTime = Date.now() + 60000;
|
|
12
28
|
this.http = axios_1.default.create({
|
|
13
29
|
baseURL: this.options.dsn,
|
|
14
30
|
headers: this.buildHeaders(options),
|
|
15
31
|
timeout: this.options.timeoutMs ?? 5000,
|
|
16
32
|
});
|
|
17
33
|
}
|
|
18
|
-
async connect() {
|
|
19
|
-
}
|
|
20
|
-
async disconnect() {
|
|
21
|
-
}
|
|
22
34
|
buildHeaders(options) {
|
|
23
35
|
if (!options.apiKey)
|
|
24
36
|
return options.headers;
|
|
@@ -27,17 +39,53 @@ class BuggLens {
|
|
|
27
39
|
[options.apiKeyHeader ?? 'x-api-key']: options.apiKey,
|
|
28
40
|
};
|
|
29
41
|
}
|
|
30
|
-
capture(error) {
|
|
42
|
+
capture(error, context) {
|
|
43
|
+
if (this.options.ignoreErrors?.some((E) => E && error instanceof E))
|
|
44
|
+
return;
|
|
31
45
|
const occurredAt = new Date();
|
|
46
|
+
if (this.isRateLimited())
|
|
47
|
+
return;
|
|
32
48
|
setImmediate(() => {
|
|
33
|
-
void this.captureAsync(error, occurredAt).catch(() => undefined);
|
|
49
|
+
void this.captureAsync(error, context, occurredAt).catch(() => undefined);
|
|
34
50
|
});
|
|
35
51
|
}
|
|
36
|
-
|
|
37
|
-
const
|
|
52
|
+
isRateLimited() {
|
|
53
|
+
const maxLimit = this.options.maxRateLimit ?? 250;
|
|
54
|
+
if (!maxLimit)
|
|
55
|
+
return false;
|
|
56
|
+
const now = Date.now();
|
|
57
|
+
if (now >= this.windowResetTime) {
|
|
58
|
+
this.errorCount = 0;
|
|
59
|
+
this.windowResetTime = now + 60000;
|
|
60
|
+
}
|
|
61
|
+
if (this.errorCount >= maxLimit) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
this.errorCount++;
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
async captureAsync(error, context, occurredAt) {
|
|
68
|
+
const frame = this.extractFrame(error);
|
|
38
69
|
if (!frame)
|
|
39
70
|
return;
|
|
40
|
-
await this.sendSourceContext(
|
|
71
|
+
const sourceContext = await this.sendSourceContext(frame);
|
|
72
|
+
const meta = await this.extractErrorMeta(error);
|
|
73
|
+
let request = {};
|
|
74
|
+
if (context.getType() === 'http') {
|
|
75
|
+
const http = context.switchToHttp();
|
|
76
|
+
const req = http.getRequest();
|
|
77
|
+
Object.assign(request, {
|
|
78
|
+
url: req.url,
|
|
79
|
+
method: req.method,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
await this.http.post('', {
|
|
83
|
+
frame,
|
|
84
|
+
sourceContext,
|
|
85
|
+
meta,
|
|
86
|
+
request,
|
|
87
|
+
occurredAt
|
|
88
|
+
});
|
|
41
89
|
}
|
|
42
90
|
extractErrorMeta(error) {
|
|
43
91
|
const match = /^([A-Za-z]+(?:Error|Exception)?): (.+)$/m.exec(error.stack ?? '');
|
|
@@ -56,22 +104,24 @@ class BuggLens {
|
|
|
56
104
|
catch {
|
|
57
105
|
sourceContext = frame;
|
|
58
106
|
}
|
|
59
|
-
await this.http.post('/errors', sourceContext);
|
|
107
|
+
// await this.http.post('/errors', sourceContext);
|
|
60
108
|
}
|
|
61
|
-
extractFrame(error
|
|
109
|
+
extractFrame(error) {
|
|
62
110
|
const match = /\((.+):(\d+):(\d+)\)/.exec(error.stack ?? '');
|
|
63
111
|
if (!match)
|
|
64
112
|
return null;
|
|
65
113
|
const [, file, line, column] = match;
|
|
66
|
-
const meta = this.extractErrorMeta(error);
|
|
67
114
|
return {
|
|
68
|
-
...meta,
|
|
69
115
|
file,
|
|
70
116
|
line: Number(line),
|
|
71
117
|
column: Number(column),
|
|
72
|
-
occurredAt
|
|
73
118
|
};
|
|
74
119
|
}
|
|
75
|
-
}
|
|
120
|
+
};
|
|
76
121
|
exports.BuggLens = BuggLens;
|
|
122
|
+
exports.BuggLens = BuggLens = __decorate([
|
|
123
|
+
(0, common_1.Injectable)(),
|
|
124
|
+
__param(0, (0, common_1.Inject)(bugg_lens_module_1.BUGG_LENS_OPTIONS)),
|
|
125
|
+
__metadata("design:paramtypes", [Object])
|
|
126
|
+
], BuggLens);
|
|
77
127
|
//# sourceMappingURL=bugg-lens.js.map
|
package/dist/bugg-lens.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bugg-lens.js","sourceRoot":"","sources":["../bugg-lens.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bugg-lens.js","sourceRoot":"","sources":["../bugg-lens.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,kDAA6C;AAC7C,qDAA0E;AAC1E,2CAAsE;AACtE,yDAAuD;AAoBhD,IAAM,QAAQ,GAAd,MAAM,QAAQ;IAKjB,YAC+B,OAAyC;QAAxB,YAAO,GAAP,OAAO,CAAiB;QAJhE,eAAU,GAAG,CAAC,CAAA;QACd,oBAAe,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;QAKzC,IAAI,CAAC,IAAI,GAAG,eAAK,CAAC,MAAM,CAAC;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO,CAA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AAK,EAAE,WAAW,EAAE,IAAI,IAAI,cAAc;YAChD,KAAK,EAAE,KAAK,EAAE,KAAK,IAAI,0BAA0B;SACpD,CAAC;IACN,CAAC;IAEO,KAAK,CAAC,iBAAiB,CAAC,KAAY;QAExC,IAAI,aAAa,GAA0B,KAAK,CAAC;QAEjD,IAAI,CAAC;YACD,aAAa,GAAG,MAAM,IAAA,iCAAgB,EAAC,KAAK,CAAC,CAAC;QAClD,CAAC;QAAC,MAAM,CAAC;YACL,aAAa,GAAG,KAAK,CAAC;QAC1B,CAAC;QAED,kDAAkD;IACtD,CAAC;IAEO,YAAY,CAAC,KAAY;QAE7B,MAAM,KAAK,GAAG,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;QAE7D,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QAExB,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC;QAGrC,OAAO;YACH,IAAI;YACJ,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC;YAClB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;SACzB,CAAC;IACN,CAAC;CACJ,CAAA;AAtIY,4BAAQ;mBAAR,QAAQ;IADpB,IAAA,mBAAU,GAAE;IAOJ,WAAA,IAAA,eAAM,EAAC,oCAAiB,CAAC,CAAA;;GANrB,QAAQ,CAsIpB"}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import { DynamicModule
|
|
2
|
-
import { BuggLensOptions
|
|
3
|
-
export declare const
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
export declare class BuggLensModule implements OnModuleInit, OnModuleDestroy {
|
|
7
|
-
private readonly buggLens;
|
|
8
|
-
static forRoot(options: BuggLensModuleOptions): DynamicModule;
|
|
9
|
-
constructor(buggLens: BuggLens);
|
|
10
|
-
onModuleInit(): Promise<void>;
|
|
11
|
-
onModuleDestroy(): Promise<void>;
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { BuggLensOptions } from './bugg-lens';
|
|
3
|
+
export declare const BUGG_LENS_OPTIONS: unique symbol;
|
|
4
|
+
export declare class BuggLensModule {
|
|
5
|
+
static register(options: BuggLensOptions): DynamicModule;
|
|
12
6
|
}
|
|
13
7
|
//# sourceMappingURL=bugg-lens.module.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bugg-lens.module.d.ts","sourceRoot":"","sources":["../bugg-lens.module.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,
|
|
1
|
+
{"version":3,"file":"bugg-lens.module.d.ts","sourceRoot":"","sources":["../bugg-lens.module.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EAEhB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAY,MAAM,aAAa,CAAC;AAIxD,eAAO,MAAM,iBAAiB,eAA8B,CAAA;AAE5D,qBACa,cAAc;IACvB,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,aAAa;CAkB3D"}
|
package/dist/bugg-lens.module.js
CHANGED
|
@@ -5,45 +5,36 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
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
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
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
8
|
var BuggLensModule_1;
|
|
15
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.BuggLensModule = exports.
|
|
10
|
+
exports.BuggLensModule = exports.BUGG_LENS_OPTIONS = void 0;
|
|
17
11
|
const common_1 = require("@nestjs/common");
|
|
18
12
|
const bugg_lens_1 = require("./bugg-lens");
|
|
19
|
-
|
|
13
|
+
const core_1 = require("@nestjs/core");
|
|
14
|
+
const bugg_lens_interceptor_1 = require("./bugg-lens.interceptor");
|
|
15
|
+
exports.BUGG_LENS_OPTIONS = Symbol('BUGG_LENS_OPTIONS');
|
|
20
16
|
let BuggLensModule = BuggLensModule_1 = class BuggLensModule {
|
|
21
|
-
static
|
|
22
|
-
const buggLensProvider = {
|
|
23
|
-
provide: exports.BUGG_LENS,
|
|
24
|
-
useFactory: () => new bugg_lens_1.BuggLens(options),
|
|
25
|
-
};
|
|
17
|
+
static register(options) {
|
|
26
18
|
return {
|
|
27
19
|
module: BuggLensModule_1,
|
|
28
|
-
providers: [
|
|
29
|
-
|
|
20
|
+
providers: [
|
|
21
|
+
{
|
|
22
|
+
provide: exports.BUGG_LENS_OPTIONS,
|
|
23
|
+
useValue: options
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
provide: core_1.APP_INTERCEPTOR,
|
|
27
|
+
useClass: bugg_lens_interceptor_1.BuggLensInterceptor,
|
|
28
|
+
},
|
|
29
|
+
bugg_lens_1.BuggLens
|
|
30
|
+
],
|
|
31
|
+
exports: [bugg_lens_1.BuggLens],
|
|
30
32
|
global: true,
|
|
31
33
|
};
|
|
32
34
|
}
|
|
33
|
-
constructor(buggLens) {
|
|
34
|
-
this.buggLens = buggLens;
|
|
35
|
-
}
|
|
36
|
-
async onModuleInit() {
|
|
37
|
-
await this.buggLens.connect();
|
|
38
|
-
}
|
|
39
|
-
async onModuleDestroy() {
|
|
40
|
-
await this.buggLens.disconnect();
|
|
41
|
-
}
|
|
42
35
|
};
|
|
43
36
|
exports.BuggLensModule = BuggLensModule;
|
|
44
37
|
exports.BuggLensModule = BuggLensModule = BuggLensModule_1 = __decorate([
|
|
45
|
-
(0, common_1.Module)({})
|
|
46
|
-
__param(0, (0, common_1.Inject)(exports.BUGG_LENS)),
|
|
47
|
-
__metadata("design:paramtypes", [bugg_lens_1.BuggLens])
|
|
38
|
+
(0, common_1.Module)({})
|
|
48
39
|
], BuggLensModule);
|
|
49
40
|
//# sourceMappingURL=bugg-lens.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bugg-lens.module.js","sourceRoot":"","sources":["../bugg-lens.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bugg-lens.module.js","sourceRoot":"","sources":["../bugg-lens.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAGwB;AACxB,2CAAwD;AACxD,uCAA8C;AAC9C,mEAA8D;AAEjD,QAAA,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAA;AAGrD,IAAM,cAAc,sBAApB,MAAM,cAAc;IACvB,MAAM,CAAC,QAAQ,CAAC,OAAwB;QACpC,OAAO;YACH,MAAM,EAAE,gBAAc;YACtB,SAAS,EAAE;gBACP;oBACI,OAAO,EAAE,yBAAiB;oBAC1B,QAAQ,EAAE,OAAO;iBACpB;gBACD;oBACI,OAAO,EAAE,sBAAe;oBACxB,QAAQ,EAAE,2CAAmB;iBAChC;gBACD,oBAAQ;aACX;YACD,OAAO,EAAE,CAAC,oBAAQ,CAAC;YACnB,MAAM,EAAE,IAAI;SACf,CAAC;IACN,CAAC;CACJ,CAAA;AAnBY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,cAAc,CAmB1B"}
|
package/dist/bugg-lens.util.d.ts
CHANGED
|
@@ -2,26 +2,13 @@ export interface Frame {
|
|
|
2
2
|
file: string;
|
|
3
3
|
line: number;
|
|
4
4
|
column: number;
|
|
5
|
-
message: string;
|
|
6
|
-
type: string;
|
|
7
|
-
name: string;
|
|
8
|
-
stack: string;
|
|
9
|
-
occurredAt: Date;
|
|
10
5
|
}
|
|
11
6
|
export interface SourceContext {
|
|
12
|
-
file: string;
|
|
13
|
-
line: number;
|
|
14
|
-
column: number;
|
|
15
7
|
startLine: number;
|
|
16
8
|
endLine: number;
|
|
17
9
|
code: string;
|
|
18
10
|
preContext: string[];
|
|
19
11
|
postContext: string[];
|
|
20
|
-
message: string;
|
|
21
|
-
type: string;
|
|
22
|
-
name: string;
|
|
23
|
-
stack: string;
|
|
24
|
-
occurredAt: Date;
|
|
25
12
|
}
|
|
26
13
|
export declare function getSourceContext(frame: Frame): Promise<SourceContext>;
|
|
27
14
|
//# sourceMappingURL=bugg-lens.util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bugg-lens.util.d.ts","sourceRoot":"","sources":["../bugg-lens.util.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,KAAK;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"bugg-lens.util.d.ts","sourceRoot":"","sources":["../bugg-lens.util.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,KAAK;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;CACzB;AAMD,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,aAAa,CAAC,CAG3E"}
|
package/dist/bugg-lens.util.js
CHANGED
|
@@ -41,7 +41,7 @@ const fs = __importStar(require("node:fs"));
|
|
|
41
41
|
const path = __importStar(require("node:path"));
|
|
42
42
|
const piscina_1 = __importDefault(require("piscina"));
|
|
43
43
|
const WORKER_PATH = path.resolve(__dirname, 'bugg-lens.worker.js');
|
|
44
|
-
const pool = new piscina_1.default({ filename: WORKER_PATH, maxThreads:
|
|
44
|
+
const pool = new piscina_1.default({ filename: WORKER_PATH, maxThreads: 2 });
|
|
45
45
|
async function getSourceContext(frame) {
|
|
46
46
|
const source = await fs.promises.readFile(frame.file, 'utf8');
|
|
47
47
|
return pool.run({ ...frame, source });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bugg-lens.util.js","sourceRoot":"","sources":["../bugg-lens.util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"bugg-lens.util.js","sourceRoot":"","sources":["../bugg-lens.util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,4CAGC;AA1BD,4CAA8B;AAC9B,gDAAkC;AAElC,sDAA8B;AAgB9B,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC;AAEnE,MAAM,IAAI,GAAG,IAAI,iBAAO,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAA;AAE3D,KAAK,UAAU,gBAAgB,CAAC,KAAY;IAC/C,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC9D,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bugg-lens.worker.d.ts","sourceRoot":"","sources":["../bugg-lens.worker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE7D,UAAU,WAAY,SAAQ,KAAK;IAC/B,MAAM,EAAE,MAAM,CAAC;CAClB;AAeD,iBAAS,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,aAAa,
|
|
1
|
+
{"version":3,"file":"bugg-lens.worker.d.ts","sourceRoot":"","sources":["../bugg-lens.worker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE7D,UAAU,WAAY,SAAQ,KAAK;IAC/B,MAAM,EAAE,MAAM,CAAC;CAClB;AAeD,iBAAS,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,aAAa,CAiCjD;AAED,SAAS,MAAM,CAAC"}
|
package/dist/bugg-lens.worker.js
CHANGED
|
@@ -54,19 +54,11 @@ function worker(input) {
|
|
|
54
54
|
const endLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line + 1;
|
|
55
55
|
const lines = source.split('\n');
|
|
56
56
|
return {
|
|
57
|
-
file: frame.file,
|
|
58
|
-
line: frame.line,
|
|
59
|
-
column: frame.column,
|
|
60
57
|
startLine,
|
|
61
58
|
endLine,
|
|
62
59
|
code: lines.slice(startLine - 1, endLine).join('\n'),
|
|
63
60
|
preContext: lines.slice(Math.max(0, startLine - 4), startLine - 1),
|
|
64
61
|
postContext: lines.slice(endLine, Math.min(lines.length, endLine + 3)),
|
|
65
|
-
message: frame.message,
|
|
66
|
-
stack: frame.stack,
|
|
67
|
-
type: frame.type,
|
|
68
|
-
name: frame.name,
|
|
69
|
-
occurredAt: frame.occurredAt
|
|
70
62
|
};
|
|
71
63
|
}
|
|
72
64
|
module.exports = worker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bugg-lens.worker.js","sourceRoot":"","sources":["../bugg-lens.worker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;AAOjC,SAAS,QAAQ,CAAC,IAAa,EAAE,GAAW;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"name": "bugg-lens-nestjs",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "NestJS integration for Bugg Lens.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": ""
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": ""
|
|
13
|
+
},
|
|
14
|
+
"homepage": "",
|
|
15
|
+
"main": "dist/index.js",
|
|
16
|
+
"types": "dist/index.d.ts",
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"README.md",
|
|
20
|
+
"LICENSE"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc -p tsconfig.json",
|
|
24
|
+
"clean": "rm -rf dist",
|
|
25
|
+
"prepack": "npm run build",
|
|
26
|
+
"test": "npm run build && node smoke-test.cjs"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"bugg-lens",
|
|
30
|
+
"nestjs",
|
|
31
|
+
"errors",
|
|
32
|
+
"monitoring"
|
|
33
|
+
],
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"axios": "^1.18.0",
|
|
39
|
+
"piscina": "^4.6.1",
|
|
40
|
+
"typescript": "^5.5.0"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@nestjs/common": "^11.0.0",
|
|
44
|
+
"rxjs": "^7.8.1",
|
|
45
|
+
"@nestjs/core": "^11.1.14"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@nestjs/common": "^11.0.0",
|
|
49
|
+
"@types/node": "^20.0.0"
|
|
50
|
+
}
|
|
51
|
+
}
|