Skip to content

Commit 5444f0c

Browse files
Merge pull request #2 from thiagobustamante/master
Performance improvement
2 parents c43645a + 39132b7 commit 5444f0c

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/idempotency-http-wrapper.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,19 @@ const getRequestId = (event: any, options: IdempotencyHttpOptionsId): any => {
4949
export const idempotencyHttpWrapper = (
5050
options: IdempotencyHttpOptions
5151
): CallableFunction => {
52+
const provider = new DynamoDB({
53+
tableName: options.provider.tableName,
54+
region: options.provider.region,
55+
endpoint: options.provider.endpoint,
56+
ttl: options.ttl ?? DEFAULT_TTL,
57+
});
5258
return async (event: any, context: any): Promise<any> => {
5359
const messageId = getRequestId(event, options.id);
5460

5561
if (isEmpty(messageId)) {
5662
return options.handler(event, context);
5763
}
5864

59-
const provider = new DynamoDB({
60-
tableName: options.provider.tableName,
61-
region: options.provider.region,
62-
endpoint: options.provider.endpoint,
63-
ttl: options.ttl ?? DEFAULT_TTL,
64-
});
65-
6665
const hasProcessed = await provider.isProcessing(messageId);
6766

6867
if (hasProcessed) {

0 commit comments

Comments
 (0)