@bifravst/http-api-mock 1.4.95 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdk/resources/http-api-mock-lambda.ts +1 -2
- package/dist/cdk/resources/http-api-mock-lambda.js +1 -2
- package/dist/src/responses.js +1 -2
- package/package.json +1 -1
- package/src/responses.ts +1 -2
- package/dist/src/URLSearchParamsToObject.d.ts +0 -1
- package/dist/src/URLSearchParamsToObject.js +0 -7
- package/dist/src/URLSearchParamsToObject.spec.d.ts +0 -1
- package/dist/src/URLSearchParamsToObject.spec.js +0 -13
- package/src/URLSearchParamsToObject.spec.ts +0 -22
- package/src/URLSearchParamsToObject.ts +0 -9
|
@@ -14,7 +14,6 @@ import { URLSearchParams } from 'url'
|
|
|
14
14
|
import { checkMatchingQueryParams } from './checkMatchingQueryParams.js'
|
|
15
15
|
import { splitMockResponse } from './splitMockResponse.js'
|
|
16
16
|
import { sortQueryString } from '../../src/sortQueryString.js'
|
|
17
|
-
import { URLSearchParamsToObject } from '../../src/URLSearchParamsToObject.js'
|
|
18
17
|
|
|
19
18
|
const db = new DynamoDBClient({})
|
|
20
19
|
|
|
@@ -44,7 +43,7 @@ export const handler = async (
|
|
|
44
43
|
requestId: context.awsRequestId,
|
|
45
44
|
method: event.httpMethod,
|
|
46
45
|
path,
|
|
47
|
-
query: query === undefined ? null :
|
|
46
|
+
query: query === undefined ? null : Object.fromEntries(query),
|
|
48
47
|
body: event.body ?? '{}',
|
|
49
48
|
headers: JSON.stringify(event.headers),
|
|
50
49
|
ttl: Math.round(Date.now() / 1000) + 5 * 60,
|
|
@@ -4,7 +4,6 @@ import { URLSearchParams } from 'url';
|
|
|
4
4
|
import { checkMatchingQueryParams } from './checkMatchingQueryParams.js';
|
|
5
5
|
import { splitMockResponse } from './splitMockResponse.js';
|
|
6
6
|
import { sortQueryString } from '../../src/sortQueryString.js';
|
|
7
|
-
import { URLSearchParamsToObject } from '../../src/URLSearchParamsToObject.js';
|
|
8
7
|
const db = new DynamoDBClient({});
|
|
9
8
|
export const handler = async (event, context) => {
|
|
10
9
|
console.log(JSON.stringify({ event }));
|
|
@@ -22,7 +21,7 @@ export const handler = async (event, context) => {
|
|
|
22
21
|
requestId: context.awsRequestId,
|
|
23
22
|
method: event.httpMethod,
|
|
24
23
|
path,
|
|
25
|
-
query: query === undefined ? null :
|
|
24
|
+
query: query === undefined ? null : Object.fromEntries(query),
|
|
26
25
|
body: event.body ?? '{}',
|
|
27
26
|
headers: JSON.stringify(event.headers),
|
|
28
27
|
ttl: Math.round(Date.now() / 1000) + 5 * 60,
|
package/dist/src/responses.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { PutItemCommand } from '@aws-sdk/client-dynamodb';
|
|
2
2
|
import { marshall } from '@aws-sdk/util-dynamodb';
|
|
3
3
|
import { sortQuery } from './sortQueryString.js';
|
|
4
|
-
import { URLSearchParamsToObject } from './URLSearchParamsToObject.js';
|
|
5
4
|
export const registerResponse = async (db, responsesTable, response) => {
|
|
6
5
|
await db.send(new PutItemCommand({
|
|
7
6
|
TableName: responsesTable,
|
|
@@ -11,7 +10,7 @@ export const registerResponse = async (db, responsesTable, response) => {
|
|
|
11
10
|
statusCode: response.statusCode,
|
|
12
11
|
body: response.body,
|
|
13
12
|
queryParams: response.queryParams !== undefined
|
|
14
|
-
?
|
|
13
|
+
? Object.fromEntries(response.queryParams)
|
|
15
14
|
: undefined,
|
|
16
15
|
ttl: response.ttl,
|
|
17
16
|
keep: response.keep,
|
package/package.json
CHANGED
package/src/responses.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { PutItemCommand, type DynamoDBClient } from '@aws-sdk/client-dynamodb'
|
|
2
2
|
import { marshall } from '@aws-sdk/util-dynamodb'
|
|
3
3
|
import { sortQuery } from './sortQueryString.js'
|
|
4
|
-
import { URLSearchParamsToObject } from './URLSearchParamsToObject.js'
|
|
5
4
|
|
|
6
5
|
export type Response = {
|
|
7
6
|
// e.g. 'GET'
|
|
@@ -37,7 +36,7 @@ export const registerResponse = async (
|
|
|
37
36
|
body: response.body,
|
|
38
37
|
queryParams:
|
|
39
38
|
response.queryParams !== undefined
|
|
40
|
-
?
|
|
39
|
+
? Object.fromEntries(response.queryParams)
|
|
41
40
|
: undefined,
|
|
42
41
|
ttl: response.ttl,
|
|
43
42
|
keep: response.keep,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const URLSearchParamsToObject: (params: URLSearchParams) => Record<string, string>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { describe, it } from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import { URLSearchParamsToObject } from './URLSearchParamsToObject.js';
|
|
4
|
-
void describe('URLSearchParamsToObject()', () => {
|
|
5
|
-
void it('should convert URLSearchParams to a plain object', () => assert.deepEqual(URLSearchParamsToObject(new URLSearchParams('eci=73393515&tac=132&requestType=custom&mcc=397&mnc=73&customTypes=2')), {
|
|
6
|
-
eci: '73393515',
|
|
7
|
-
tac: '132',
|
|
8
|
-
requestType: 'custom',
|
|
9
|
-
mcc: '397',
|
|
10
|
-
mnc: '73',
|
|
11
|
-
customTypes: '2',
|
|
12
|
-
}));
|
|
13
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { describe, it } from 'node:test'
|
|
2
|
-
import assert from 'node:assert/strict'
|
|
3
|
-
import { URLSearchParamsToObject } from './URLSearchParamsToObject.js'
|
|
4
|
-
|
|
5
|
-
void describe('URLSearchParamsToObject()', () => {
|
|
6
|
-
void it('should convert URLSearchParams to a plain object', () =>
|
|
7
|
-
assert.deepEqual(
|
|
8
|
-
URLSearchParamsToObject(
|
|
9
|
-
new URLSearchParams(
|
|
10
|
-
'eci=73393515&tac=132&requestType=custom&mcc=397&mnc=73&customTypes=2',
|
|
11
|
-
),
|
|
12
|
-
),
|
|
13
|
-
{
|
|
14
|
-
eci: '73393515',
|
|
15
|
-
tac: '132',
|
|
16
|
-
requestType: 'custom',
|
|
17
|
-
mcc: '397',
|
|
18
|
-
mnc: '73',
|
|
19
|
-
customTypes: '2',
|
|
20
|
-
},
|
|
21
|
-
))
|
|
22
|
-
})
|