-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
7,908 additions
and
5,322 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,43 @@ | ||
// Include dynalite and config server (use in memory) | ||
// @ts-ignore: No type file available | ||
import dynalite from 'dynalite' | ||
import { DynamoDBClient } from '@aws-sdk/client-dynamodb' | ||
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb' | ||
|
||
export const dynaliteServer = dynalite({ | ||
createTableMs: 0, | ||
updateTableMs: 0, | ||
deleteTableMs: 0 | ||
}) | ||
const marshallOptions = { | ||
// Whether to automatically convert empty strings, blobs, and sets to `null`. | ||
convertEmptyValues: false, // false, by default. | ||
// Whether to remove undefined values while marshalling. | ||
removeUndefinedValues: false, // false, by default. | ||
// Whether to convert typeof object to map attribute. | ||
convertClassInstanceToMap: false, // false, by default. | ||
} | ||
|
||
// Load AWS SDK | ||
import AWS from 'aws-sdk' | ||
const unmarshallOptions = { | ||
// Whether to return numbers as a string instead of converting them to native JavaScript numbers. | ||
wrapNumbers: false, // false, by default. | ||
} | ||
|
||
// Create DynamoDB connection to dynalite | ||
export const DynamoDB = new AWS.DynamoDB({ | ||
endpoint: 'http://localhost:4567', | ||
region: 'us-east-1', | ||
credentials: new AWS.Credentials({ | ||
accessKeyId: 'test', | ||
secretAccessKey: 'test' | ||
}) | ||
}) | ||
const translateConfig = { marshallOptions, unmarshallOptions } | ||
|
||
// Create our document client | ||
export const DocumentClient = new AWS.DynamoDB.DocumentClient({ | ||
export const DocumentClient = DynamoDBDocumentClient.from(new DynamoDBClient({ | ||
endpoint: 'http://localhost:4567', | ||
region: 'us-east-1', | ||
credentials: new AWS.Credentials({ | ||
credentials: { | ||
accessKeyId: 'test', | ||
secretAccessKey: 'test' | ||
}) | ||
// convertEmptyValues: true | ||
}) | ||
secretAccessKey: 'test', | ||
}, | ||
}), translateConfig) | ||
|
||
export const DocumentClientWrappedNumbers = new AWS.DynamoDB.DocumentClient({ | ||
|
||
export const DocumentClientWithWrappedNumbers = DynamoDBDocumentClient.from(new DynamoDBClient({ | ||
endpoint: 'http://localhost:4567', | ||
region: 'us-east-1', | ||
credentials: new AWS.Credentials({ | ||
credentials: { | ||
accessKeyId: 'test', | ||
secretAccessKey: 'test' | ||
}), | ||
wrapNumbers: true | ||
}) | ||
|
||
// Delay helper | ||
export const delay = (ms: number) => new Promise(res => setTimeout(res, ms)) | ||
|
||
export const DocumentClient2 = new AWS.DynamoDB.DocumentClient({ | ||
region: 'us-east-1', | ||
credentials: new AWS.SharedIniFileCredentials({ profile: '' }) | ||
// convertEmptyValues: false | ||
secretAccessKey: 'test', | ||
}, | ||
}), { | ||
...translateConfig, | ||
unmarshallOptions: { | ||
...translateConfig.unmarshallOptions, | ||
wrapNumbers: true, | ||
} | ||
}) |
Oops, something went wrong.