Skip to content

Commit 402495f

Browse files
committed
lint
1 parent 98dd7ce commit 402495f

2 files changed

Lines changed: 19 additions & 25 deletions

File tree

lambdas/authorizer/src/__tests__/index.test.ts

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ jest.mock("aws-embedded-metrics", () => {
1717
};
1818

1919
return {
20-
metricScope: jest.fn((handler: (metrics: typeof metricsMock) => unknown) => {
21-
const wrapped = handler(metricsMock);
22-
if (typeof wrapped === "function") {
23-
return wrapped();
24-
}
25-
return undefined;
26-
}),
20+
metricScope: jest.fn(
21+
(handler: (metrics: typeof metricsMock) => unknown) => {
22+
const wrapped = handler(metricsMock);
23+
if (typeof wrapped === "function") {
24+
return wrapped();
25+
}
26+
},
27+
),
2728
__metricsMock: metricsMock,
2829
};
2930
});
@@ -80,14 +81,9 @@ describe("Authorizer Lambda Function", () => {
8081
.useFakeTimers({ doNotFake: ["nextTick"] })
8182
.setSystemTime(new Date("2025-11-03T14:19:00Z"));
8283
(metricScope as jest.Mock).mockClear();
83-
const metricsMock = (jest.requireMock(
84+
const metricsMock = jest.requireMock(
8485
"aws-embedded-metrics",
85-
) as {
86-
__metricsMock: {
87-
setNamespace: jest.Mock;
88-
putMetric: jest.Mock;
89-
};
90-
}).__metricsMock;
86+
).__metricsMock;
9187
metricsMock.setNamespace.mockClear();
9288
metricsMock.putMetric.mockClear();
9389
});
@@ -115,12 +111,9 @@ describe("Authorizer Lambda Function", () => {
115111
handler(mockEvent, mockContext, mockCallback);
116112
await new Promise(process.nextTick);
117113

118-
const metricsMock = (jest.requireMock("aws-embedded-metrics") as {
119-
__metricsMock: {
120-
setNamespace: jest.Mock;
121-
putMetric: jest.Mock;
122-
};
123-
}).__metricsMock;
114+
const metricsMock = jest.requireMock(
115+
"aws-embedded-metrics",
116+
).__metricsMock;
124117

125118
expect(metricScope).toHaveBeenCalledTimes(1);
126119
expect(metricsMock.setNamespace).toHaveBeenCalledWith("authorizer");

lambdas/authorizer/src/authorizer.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
APIGatewayRequestAuthorizerHandler,
77
Callback,
88
Context,
9-
} from "aws-lambda"
9+
} from "aws-lambda";
1010
import { MetricsLogger, metricScope } from "aws-embedded-metrics";
1111
import { Supplier } from "@internal/datastore";
1212
import { Deps } from "./deps";
@@ -120,11 +120,12 @@ async function checkCertificateExpiry(
120120
const expiry = getCertificateExpiryInDays(certificate);
121121

122122
if (expiry <= deps.env.CLIENT_CERTIFICATE_EXPIRATION_ALERT_DAYS) {
123-
metricScope(
124-
(metrics: MetricsLogger) => async () => {
123+
metricScope((metrics: MetricsLogger) => async () => {
125124
deps.logger.warn(`APIM Certificated expiry in ${expiry} days`);
126-
metrics.setNamespace(process.env.AWS_LAMBDA_FUNCTION_NAME || 'authorizer');
125+
metrics.setNamespace(
126+
process.env.AWS_LAMBDA_FUNCTION_NAME || "authorizer",
127+
);
127128
metrics.putMetric("apim-client-certificate-near-expiry", expiry, "Count");
128129
});
129-
};
130+
}
130131
}

0 commit comments

Comments
 (0)