Skip to content

Commit 3b89362

Browse files
committed
Removeed some use of any
1 parent bc527d3 commit 3b89362

File tree

3 files changed

+8
-35
lines changed

3 files changed

+8
-35
lines changed

packages/event-handler/src/types/rest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type ErrorHandler<T extends Error = Error> = (
2424
) => Promise<HandlerResponse>;
2525

2626
interface ErrorConstructor<T extends Error = Error> {
27-
new (...args: any[]): T;
27+
new (...args: unknown[]): T;
2828
prototype: T;
2929
}
3030

packages/event-handler/tests/unit/rest/converters.test.ts

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,15 @@
1-
import type { APIGatewayProxyEvent } from 'aws-lambda';
21
import { describe, expect, it } from 'vitest';
32
import {
43
handlerResultToProxyResult,
54
handlerResultToWebResponse,
65
proxyEventToWebRequest,
76
webResponseToProxyResult,
87
} from '../../../src/rest/index.js';
8+
import { createTestEvent } from './helpers.js';
99

1010
describe('Converters', () => {
1111
describe('proxyEventToWebRequest', () => {
12-
const baseEvent: APIGatewayProxyEvent = {
13-
httpMethod: 'GET',
14-
path: '/test',
15-
resource: '/test',
16-
headers: {},
17-
multiValueHeaders: {},
18-
queryStringParameters: null,
19-
multiValueQueryStringParameters: {},
20-
pathParameters: null,
21-
stageVariables: null,
22-
requestContext: {
23-
accountId: '123456789012',
24-
apiId: 'test-api',
25-
httpMethod: 'GET',
26-
path: '/test',
27-
requestId: 'test-request-id',
28-
resourceId: 'test-resource',
29-
resourcePath: '/test',
30-
stage: 'test',
31-
domainName: 'api.example.com',
32-
identity: {
33-
sourceIp: '127.0.0.1',
34-
},
35-
} as any,
36-
isBase64Encoded: false,
37-
body: null,
38-
};
12+
const baseEvent = createTestEvent('/test', 'GET');
3913

4014
it('converts basic GET request', () => {
4115
// Prepare & Act
@@ -65,17 +39,16 @@ describe('Converters', () => {
6539

6640
it('uses X-Forwarded-Proto header for protocol', () => {
6741
// Prepare
68-
const event = {
69-
...baseEvent,
70-
headers: { 'X-Forwarded-Proto': 'https' },
71-
};
42+
const event = createTestEvent('/test', 'GET', {
43+
'X-Forwarded-Proto': 'http',
44+
});
7245

7346
// Act
7447
const request = proxyEventToWebRequest(event);
7548

7649
// Assess
7750
expect(request).toBeInstanceOf(Request);
78-
expect(request.url).toBe('https://api.example.com/test');
51+
expect(request.url).toBe('http://api.example.com/test');
7952
});
8053

8154
it('handles null values in multiValueHeaders arrays', () => {

packages/event-handler/tests/unit/rest/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const createTestEvent = (
1919
requestContext: {
2020
httpMethod,
2121
path,
22-
domainName: 'localhost',
22+
domainName: 'api.example.com',
2323
} as APIGatewayProxyEvent['requestContext'],
2424
resource: '',
2525
});

0 commit comments

Comments
 (0)