Skip to content

Commit 388df44

Browse files
committed
lint
1 parent d09f34d commit 388df44

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

src/metrics/graphql.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,24 @@ export const gqlResolverDuration = new client.Histogram({
3838
* Apollo Server plugin to track GraphQL metrics
3939
*/
4040
export const graphqlMetricsPlugin: ApolloServerPlugin = {
41-
async requestDidStart(requestContext: GraphQLRequestContext): Promise<GraphQLRequestListener> {
41+
async requestDidStart(_requestContext: GraphQLRequestContext): Promise<GraphQLRequestListener> {
4242
const startTime = Date.now();
4343
let operationName = 'unknown';
4444
let operationType = 'unknown';
4545

4646
return {
47-
async didResolveOperation(requestContext: GraphQLRequestContext) {
48-
operationName = requestContext.operationName || 'anonymous';
49-
operationType = requestContext.operation?.operation || 'unknown';
47+
async didResolveOperation(ctx: GraphQLRequestContext): Promise<void> {
48+
operationName = ctx.operationName || 'anonymous';
49+
operationType = ctx.operation?.operation || 'unknown';
5050
},
5151

52-
async executionDidStart() {
52+
async executionDidStart(): Promise<GraphQLRequestListener> {
5353
return {
5454
// eslint-disable-next-line @typescript-eslint/no-explicit-any
55-
willResolveField({ info }: any) {
55+
willResolveField({ info }: any): () => void {
5656
const fieldStartTime = Date.now();
5757

58-
return () => {
58+
return (): void => {
5959
const duration = (Date.now() - fieldStartTime) / 1000;
6060

6161
gqlResolverDuration
@@ -70,16 +70,16 @@ export const graphqlMetricsPlugin: ApolloServerPlugin = {
7070
};
7171
},
7272

73-
async willSendResponse(requestContext: GraphQLRequestContext) {
73+
async willSendResponse(ctx: GraphQLRequestContext): Promise<void> {
7474
const duration = (Date.now() - startTime) / 1000;
7575

7676
gqlOperationDuration
7777
.labels(operationName, operationType)
7878
.observe(duration);
7979

8080
// Track errors if any
81-
if (requestContext.errors && requestContext.errors.length > 0) {
82-
requestContext.errors.forEach((error: GraphQLError) => {
81+
if (ctx.errors && ctx.errors.length > 0) {
82+
ctx.errors.forEach((error: GraphQLError) => {
8383
const errorType = error.extensions?.code || error.name || 'unknown';
8484

8585
gqlOperationErrors

src/metrics/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ register.registerMetric(mongoCommandErrors);
5151

5252
/**
5353
* Express middleware to track HTTP metrics
54+
* @param req - Express request object
55+
* @param res - Express response object
56+
* @param next - Express next function
5457
*/
5558
export function metricsMiddleware(req: express.Request, res: express.Response, next: express.NextFunction): void {
5659
const start = Date.now();

src/metrics/mongodb.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ export function setupMongoMetrics(client: MongoClient): void {
4444
const metadataKey = `${event.requestId}`;
4545

4646
// Extract collection name from the command
47-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
48-
console.log('event', event);
49-
50-
const collection = event.command ? ((event.command as any)[event.commandName] || 'unknown') : 'unknown';
47+
const collection = event.command ? ((event.command)[event.commandName] || 'unknown') : 'unknown';
5148
const db = event.databaseName || 'unknown';
5249

5350
// eslint-disable-next-line @typescript-eslint/no-explicit-any

0 commit comments

Comments
 (0)