Skip to content

Commit 7c2118b

Browse files
lint fixes
1 parent 242f875 commit 7c2118b

File tree

16 files changed

+308
-241
lines changed

16 files changed

+308
-241
lines changed

lambdas/mi-stream-forwarder/jest.config.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { Config } from 'jest';
1+
import type { Config } from "jest";
22

33
export const baseJestConfig: Config = {
4-
preset: 'ts-jest',
4+
preset: "ts-jest",
55

66
// Automatically clear mock calls, instances, contexts and results before every test
77
clearMocks: true,
@@ -10,10 +10,10 @@ export const baseJestConfig: Config = {
1010
collectCoverage: true,
1111

1212
// The directory where Jest should output its coverage files
13-
coverageDirectory: './.reports/unit/coverage',
13+
coverageDirectory: "./.reports/unit/coverage",
1414

1515
// Indicates which provider should be used to instrument code for coverage
16-
coverageProvider: 'babel',
16+
coverageProvider: "babel",
1717

1818
coverageThreshold: {
1919
global: {
@@ -24,36 +24,36 @@ export const baseJestConfig: Config = {
2424
},
2525
},
2626

27-
coveragePathIgnorePatterns: ['/__tests__/'],
28-
transform: { '^.+\\.ts$': 'ts-jest' },
29-
testPathIgnorePatterns: ['.build'],
30-
testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'],
27+
coveragePathIgnorePatterns: ["/__tests__/"],
28+
transform: { "^.+\\.ts$": "ts-jest" },
29+
testPathIgnorePatterns: [".build"],
30+
testMatch: ["**/?(*.)+(spec|test).[jt]s?(x)"],
3131

3232
// Use this configuration option to add custom reporters to Jest
3333
reporters: [
34-
'default',
34+
"default",
3535
[
36-
'jest-html-reporter',
36+
"jest-html-reporter",
3737
{
38-
pageTitle: 'Test Report',
39-
outputPath: './.reports/unit/test-report.html',
38+
pageTitle: "Test Report",
39+
outputPath: "./.reports/unit/test-report.html",
4040
includeFailureMsg: true,
4141
},
4242
],
4343
],
4444

4545
// The test environment that will be used for testing
46-
testEnvironment: 'jsdom',
46+
testEnvironment: "jsdom",
4747
};
4848

4949
const utilsJestConfig = {
5050
...baseJestConfig,
5151

52-
testEnvironment: 'node',
52+
testEnvironment: "node",
5353

5454
coveragePathIgnorePatterns: [
5555
...(baseJestConfig.coveragePathIgnorePatterns ?? []),
56-
'zod-validators.ts',
56+
"zod-validators.ts",
5757
],
5858
};
5959

lambdas/mi-stream-forwarder/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
{
22
"dependencies": {
33
"@aws-sdk/client-kinesis": "^3.0.0",
4-
"aws-lambda": "^1.0.7"
4+
"@aws-sdk/util-dynamodb": "^3.940.0",
5+
"@internal/datastore": "^0.1.0",
6+
"aws-lambda": "^1.0.7",
7+
"jest-mock-extended": "^4.0.0",
8+
"pino": "^10.1.0",
9+
"zod": "^4.1.13"
510
},
611
"devDependencies": {
712
"@types/aws-lambda": "^8.10.119",

lambdas/mi-stream-forwarder/src/__tests__/mi-stream-forwarder.test.ts

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
1-
import { KinesisClient } from '@aws-sdk/client-kinesis';
1+
import { KinesisClient } from "@aws-sdk/client-kinesis";
22
import * as pino from "pino";
3-
import { mockDeep } from 'jest-mock-extended';
4-
import { DynamoDBStreamEvent, Context } from 'aws-lambda';
5-
import { Deps } from '../deps';
6-
import { EnvVars } from '../env';
7-
import { createHandler } from '../mi-stream-forwarder';
8-
9-
10-
describe('mi-stream-forwarder Lambda', () => {
3+
import { mockDeep } from "jest-mock-extended";
4+
import { Context, DynamoDBStreamEvent } from "aws-lambda";
5+
import { Deps } from "../deps";
6+
import { EnvVars } from "../env";
7+
import createHandler from "../mi-stream-forwarder";
118

9+
describe("mi-stream-forwarder Lambda", () => {
1210
const mockedDeps: jest.Mocked<Deps> = {
13-
kinesisClient: { send: jest.fn()} as unknown as KinesisClient,
14-
logger: { info: jest.fn(), warn: jest.fn(), error: jest.fn() } as unknown as pino.Logger,
11+
kinesisClient: { send: jest.fn() } as unknown as KinesisClient,
12+
logger: {
13+
info: jest.fn(),
14+
warn: jest.fn(),
15+
error: jest.fn(),
16+
} as unknown as pino.Logger,
1517
env: {
1618
MI_CHANGE_STREAM_ARN: "test-stream",
17-
} as unknown as EnvVars
19+
} as unknown as EnvVars,
1820
} as Deps;
1921

2022
beforeEach(() => {
2123
jest.clearAllMocks();
2224
});
2325

24-
it('forwards INSERT records to Kinesis', async () => {
26+
it("forwards INSERT records to Kinesis", async () => {
2527
const event: DynamoDBStreamEvent = {
2628
Records: [
2729
{
28-
eventName: 'INSERT',
30+
eventName: "INSERT",
2931
dynamodb: {
30-
NewImage: { id: { S: 'mi-123' }, foo: { S: 'bar' } },
32+
NewImage: { id: { S: "mi-123" }, foo: { S: "bar" } },
3133
},
3234
},
3335
],
@@ -38,20 +40,20 @@ describe('mi-stream-forwarder Lambda', () => {
3840
expect(mockedDeps.kinesisClient.send).toHaveBeenCalledWith(
3941
expect.objectContaining({
4042
input: expect.objectContaining({
41-
StreamARN: 'test-stream',
42-
PartitionKey: 'mi-123',
43+
StreamARN: "test-stream",
44+
PartitionKey: "mi-123",
4345
}),
44-
})
46+
}),
4547
);
4648
});
4749

48-
it('does not forward non-INSERT records', async () => {
50+
it("does not forward non-INSERT records", async () => {
4951
const event: DynamoDBStreamEvent = {
5052
Records: [
5153
{
52-
eventName: 'MODIFY',
54+
eventName: "MODIFY",
5355
dynamodb: {
54-
NewImage: { id: { S: 'mi-123' }, foo: { S: 'baz' } },
56+
NewImage: { id: { S: "mi-123" }, foo: { S: "baz" } },
5557
},
5658
},
5759
],

lambdas/mi-stream-forwarder/src/deps.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import pino from 'pino';
2-
import { KinesisClient } from '@aws-sdk/client-kinesis';
3-
import { envVars, EnvVars } from './env';
1+
import pino from "pino";
2+
import { KinesisClient } from "@aws-sdk/client-kinesis";
3+
import { EnvVars, envVars } from "./env";
44

55
export type Deps = {
66
kinesisClient: KinesisClient;

lambdas/mi-stream-forwarder/src/env.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { z } from 'zod';
1+
import { z } from "zod";
22

33
const EnvVarsSchema = z.object({
44
MI_CHANGE_STREAM_ARN: z.string(),

lambdas/mi-stream-forwarder/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ import { createDependenciesContainer } from "./deps";
33

44
const container = createDependenciesContainer();
55

6-
export const handler = createHandler(container);
6+
const handler = createHandler(container);
7+
export default handler;
Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
import { MI } from "@internal/datastore";
22
import { DynamoDBStreamEvent, Handler } from "aws-lambda";
33
import { PutRecordCommand } from "@aws-sdk/client-kinesis";
4-
import { Deps } from "./deps";
54
import { unmarshall } from "@aws-sdk/util-dynamodb";
6-
import { Logger } from "pino";
5+
import { Deps } from "./deps";
76

8-
export function createHandler(deps: Deps): Handler<DynamoDBStreamEvent> {
7+
export default function createHandler(
8+
deps: Deps,
9+
): Handler<DynamoDBStreamEvent> {
910
return async (event: DynamoDBStreamEvent): Promise<void> => {
10-
deps.logger.info({description: "Received event", event});
11-
const insertedRecords = event.Records
12-
.filter(record => record.eventName === "INSERT");
11+
deps.logger.info({ description: "Received event", event });
12+
const insertedRecords = event.Records.filter(
13+
(record) => record.eventName === "INSERT",
14+
);
1315

1416
for (const record of insertedRecords) {
1517
const newImage = record.dynamodb?.NewImage!;
1618
const miRecord = unmarshall(newImage as any) as MI;
17-
await deps.kinesisClient.send(new PutRecordCommand({
18-
StreamARN: deps.env.MI_CHANGE_STREAM_ARN,
19-
PartitionKey: miRecord.id,
20-
Data: Buffer.from(JSON.stringify(miRecord)),
21-
}));
19+
await deps.kinesisClient.send(
20+
new PutRecordCommand({
21+
StreamARN: deps.env.MI_CHANGE_STREAM_ARN,
22+
PartitionKey: miRecord.id,
23+
Data: Buffer.from(JSON.stringify(miRecord)),
24+
}),
25+
);
2226
}
2327
};
2428
}

lambdas/mi-updates-transformer/jest.config.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { Config } from 'jest';
1+
import type { Config } from "jest";
22

33
export const baseJestConfig: Config = {
4-
preset: 'ts-jest',
4+
preset: "ts-jest",
55

66
// Automatically clear mock calls, instances, contexts and results before every test
77
clearMocks: true,
@@ -10,10 +10,10 @@ export const baseJestConfig: Config = {
1010
collectCoverage: true,
1111

1212
// The directory where Jest should output its coverage files
13-
coverageDirectory: './.reports/unit/coverage',
13+
coverageDirectory: "./.reports/unit/coverage",
1414

1515
// Indicates which provider should be used to instrument code for coverage
16-
coverageProvider: 'babel',
16+
coverageProvider: "babel",
1717

1818
coverageThreshold: {
1919
global: {
@@ -24,36 +24,36 @@ export const baseJestConfig: Config = {
2424
},
2525
},
2626

27-
coveragePathIgnorePatterns: ['/__tests__/'],
28-
transform: { '^.+\\.ts$': 'ts-jest' },
29-
testPathIgnorePatterns: ['.build'],
30-
testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'],
27+
coveragePathIgnorePatterns: ["/__tests__/"],
28+
transform: { "^.+\\.ts$": "ts-jest" },
29+
testPathIgnorePatterns: [".build"],
30+
testMatch: ["**/?(*.)+(spec|test).[jt]s?(x)"],
3131

3232
// Use this configuration option to add custom reporters to Jest
3333
reporters: [
34-
'default',
34+
"default",
3535
[
36-
'jest-html-reporter',
36+
"jest-html-reporter",
3737
{
38-
pageTitle: 'Test Report',
39-
outputPath: './.reports/unit/test-report.html',
38+
pageTitle: "Test Report",
39+
outputPath: "./.reports/unit/test-report.html",
4040
includeFailureMsg: true,
4141
},
4242
],
4343
],
4444

4545
// The test environment that will be used for testing
46-
testEnvironment: 'jsdom',
46+
testEnvironment: "jsdom",
4747
};
4848

4949
const utilsJestConfig = {
5050
...baseJestConfig,
5151

52-
testEnvironment: 'node',
52+
testEnvironment: "node",
5353

5454
coveragePathIgnorePatterns: [
5555
...(baseJestConfig.coveragePathIgnorePatterns ?? []),
56-
'zod-validators.ts',
56+
"zod-validators.ts",
5757
],
5858
};
5959

lambdas/mi-updates-transformer/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
{
22
"dependencies": {
3+
"@aws-sdk/client-sns": "^3.940.0",
4+
"@internal/datastore": "^0.1.0",
35
"@nhsdigital/nhs-notify-event-schemas-supplier-api": "*",
4-
"esbuild": "^0.24.0"
6+
"aws-lambda": "^1.0.7",
7+
"esbuild": "^0.24.0",
8+
"pino": "^10.1.0",
9+
"zod": "^4.1.13"
510
},
611
"devDependencies": {
712
"@tsconfig/node22": "^22.0.2",

0 commit comments

Comments
 (0)