From c65190e5e43a3aa5f50f2ce5a5b87f0977c02a6f Mon Sep 17 00:00:00 2001 From: Julien Blin Date: Wed, 19 Sep 2018 08:55:11 -0400 Subject: [PATCH] DocumentDb: Allow fine-grained customization of underlying client. --- CHANGELOG.md | 1 + packages/uno-serverless-azure/src/services/documentdb.ts | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eba92da..3119eb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - SSMParameterStoreConfigService: Added set method. - DocumentDb: Added debug mode - DocumentDb: Exposed underlying client +- DocumentDb: Allow fine-grained customization of underlying client ### Changed - [BREAKING] Removed maxresults in Azure KeyVaultConfigService options as it is not very useful (blocked at 25 anyway) diff --git a/packages/uno-serverless-azure/src/services/documentdb.ts b/packages/uno-serverless-azure/src/services/documentdb.ts index b65502c..cba9c03 100644 --- a/packages/uno-serverless-azure/src/services/documentdb.ts +++ b/packages/uno-serverless-azure/src/services/documentdb.ts @@ -93,8 +93,9 @@ export interface DocumentDbImplOptions { collectionCreationOptions?: Partial; collectionId: string | Promise; databaseId: string | Promise; - debug?: boolean | Promise; + debug?: boolean | Promise; defaultConsistencyLevel?: ConsistencyLevel; + documentClient?: DocumentClient | Promise; endpoint: string | Promise; primaryKey: string | Promise; } @@ -105,6 +106,11 @@ export class DocumentDbImpl implements DocumentDb, CheckHealth { private readonly lazyClient = lazyAsync( async () => { + const optionClient = await this.options.documentClient; + if (optionClient) { + return optionClient; + } + return new DocumentClient( await this.options.endpoint, {