From 5a347b316408c53ed3f5947fed9c1fff41c0c13c Mon Sep 17 00:00:00 2001 From: Ali Mihandoost Date: Sun, 7 May 2023 18:06:21 +0330 Subject: [PATCH 1/3] feat(storage-client): add touch method Co-authored-by: Mohammad Honarvar --- core/storage-client/src/storage-client.ts | 29 ++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/core/storage-client/src/storage-client.ts b/core/storage-client/src/storage-client.ts index 24e2bf1e6..0bd89e4da 100644 --- a/core/storage-client/src/storage-client.ts +++ b/core/storage-client/src/storage-client.ts @@ -181,7 +181,7 @@ export class AlwatrStorageClient { - this._logger.logMethodArgs?.('set', {documentId: documentObject.id}); + this._logger.logMethodArgs?.('set', {storage, documentId: documentObject.id}); if (storage == null) throw new Error('storage_not_defined'); const responseJson = await serviceRequest>({ @@ -201,6 +201,29 @@ export class AlwatrStorageClient { + this._logger.logMethodArgs?.('touch', {storage}); + if (storage == null) throw new Error('storage_not_defined'); + + await serviceRequest({ + ...this.fetchOption, + method: 'GET', + url: this.fetchOption.url + 'touch', + queryParameters: { + storage, + }, + }); + } + /** * Delete a document object from the storage. * @@ -236,7 +259,7 @@ export class AlwatrStorageClient( name: string | undefined = this.config.name, ): Promise> { - this._logger.logMethod?.('getStorage'); + this._logger.logMethodArgs?.('getStorage', {name}); if (name == null) throw new Error('storage_not_defined'); const responseJson = (await serviceRequest({ @@ -269,7 +292,7 @@ export class AlwatrStorageClient> { - this._logger.logMethod?.('keys'); + this._logger.logMethodArgs?.('keys', {storage}); if (storage == null) throw new Error('storage_not_defined'); const responseJson = await serviceRequest({ From a99ae5df13f909eba4ad5cbf6d7d04cb2a98b6f6 Mon Sep 17 00:00:00 2001 From: Ali Mihandoost Date: Sun, 7 May 2023 18:06:42 +0330 Subject: [PATCH 2/3] feat(storage-server): add touch method Co-authored-by: Mohammad Honarvar --- services/storage-server/src/route/touch.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 services/storage-server/src/route/touch.ts diff --git a/services/storage-server/src/route/touch.ts b/services/storage-server/src/route/touch.ts new file mode 100644 index 000000000..b14e17e36 --- /dev/null +++ b/services/storage-server/src/route/touch.ts @@ -0,0 +1,18 @@ +import {config, logger} from '../config.js'; +import {nanoServer} from '../lib/nano-server.js'; +import {storageProvider} from '../lib/storage-provider.js'; + +nanoServer.route('GET', '/touch', (connection) => { + logger.logMethod?.('touch'); + + connection.requireToken(config.nanoServer.accessToken); + + const params = connection.requireQueryParams<{storage: string; id: string}>({storage: 'string', id: 'string'}); + + storageProvider.get({name: params.storage}); + + return { + ok: true, + data: {}, + }; +}); From 85bb8551e2dfe976d191d7c7243c29fe71433e54 Mon Sep 17 00:00:00 2001 From: Ali Mihandoost Date: Sun, 7 May 2023 18:07:44 +0330 Subject: [PATCH 3/3] feat(storage-engine): save new empty storage after open Co-authored-by: Mohammad Honarvar --- core/storage-engine/src/storage-engine.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/core/storage-engine/src/storage-engine.ts b/core/storage-engine/src/storage-engine.ts index c88ebdac0..2d4d0bf90 100644 --- a/core/storage-engine/src/storage-engine.ts +++ b/core/storage-engine/src/storage-engine.ts @@ -172,6 +172,7 @@ export class AlwatrStorageEngine