fix(api): resolve lint errors
This commit is contained in:
1 parent
96fede9fe5
commit
fd1fa2366c
42 files changed
+307
-199
No files matched your search
@@ -38,27 +38,24 @@ export function applyMongoosePerformancePlugin(schema: mongoose.Schema): void {
|
||||
const markedSchema = schema as SchemaWithPerformanceMarker;
|
||||
if (markedSchema[PERFORMANCE_PLUGIN_APPLIED]) return;
|
||||
markedSchema[PERFORMANCE_PLUGIN_APPLIED] = true;
|
||||
const hookableSchema = schema as any;
|
||||
|
||||
hookableSchema.pre(QUERY_OPERATION_REGEX, function () {
|
||||
schema.pre(QUERY_OPERATION_REGEX, function () {
|
||||
const query = this as QueryWithPerformanceState;
|
||||
query[QUERY_PERFORMANCE_START] = process.hrtime.bigint();
|
||||
query[QUERY_PERFORMANCE_RECORDED] = false;
|
||||
});
|
||||
|
||||
hookableSchema.post(QUERY_OPERATION_REGEX, function (result: unknown) {
|
||||
recordQueryPerformance(
|
||||
this as unknown as QueryWithPerformanceState,
|
||||
result,
|
||||
);
|
||||
schema.post(QUERY_OPERATION_REGEX, function (result: unknown) {
|
||||
recordQueryPerformance(this as QueryWithPerformanceState, result);
|
||||
});
|
||||
|
||||
hookableSchema.post(
|
||||
schema.post(
|
||||
QUERY_OPERATION_REGEX,
|
||||
{ errorHandler: true },
|
||||
function (
|
||||
error: unknown,
|
||||
error: Error,
|
||||
_result: unknown,
|
||||
next: (error: unknown) => void,
|
||||
next: (error?: mongoose.CallbackError) => void,
|
||||
) {
|
||||
recordQueryPerformance(
|
||||
this as unknown as QueryWithPerformanceState,
|
||||
@@ -69,22 +66,23 @@ export function applyMongoosePerformancePlugin(schema: mongoose.Schema): void {
|
||||
},
|
||||
);
|
||||
|
||||
hookableSchema.pre('aggregate', function () {
|
||||
schema.pre('aggregate', function () {
|
||||
const aggregate = this as AggregateWithPerformanceState;
|
||||
aggregate[QUERY_PERFORMANCE_START] = process.hrtime.bigint();
|
||||
aggregate[QUERY_PERFORMANCE_RECORDED] = false;
|
||||
});
|
||||
|
||||
hookableSchema.post('aggregate', function (result: unknown) {
|
||||
schema.post('aggregate', function (result: unknown) {
|
||||
recordAggregatePerformance(this as AggregateWithPerformanceState, result);
|
||||
});
|
||||
|
||||
hookableSchema.post(
|
||||
schema.post(
|
||||
'aggregate',
|
||||
{ errorHandler: true },
|
||||
function (
|
||||
error: unknown,
|
||||
error: Error,
|
||||
_result: unknown,
|
||||
next: (error: unknown) => void,
|
||||
next: (error?: mongoose.CallbackError) => void,
|
||||
) {
|
||||
recordAggregatePerformance(
|
||||
this as AggregateWithPerformanceState,
|
||||
|
||||
Reference in new issue
Block a user