diff --git a/packages/backend/src/nest/connections-manager/connections-manager.module.ts b/packages/backend/src/nest/connections-manager/connections-manager.module.ts index 42a6238947..83b0892d3a 100644 --- a/packages/backend/src/nest/connections-manager/connections-manager.module.ts +++ b/packages/backend/src/nest/connections-manager/connections-manager.module.ts @@ -5,10 +5,10 @@ import { SocketModule } from '../socket/socket.module' import { StorageModule } from '../storage/storage.module' import { TorModule } from '../tor/tor.module' import { ConnectionsManagerService } from './connections-manager.service' -import { ServerProxyServiceModule } from '../storageServerProxy/storageServerProxy.module' +import { StorageServiceClientModule } from '../storageServiceClient/storageServiceClient.module' @Module({ - imports: [RegistrationModule, StorageModule, TorModule, SocketModule, LocalDbModule, ServerProxyServiceModule], + imports: [RegistrationModule, StorageModule, TorModule, SocketModule, LocalDbModule, StorageServiceClientModule], providers: [ConnectionsManagerService], exports: [ConnectionsManagerService], }) diff --git a/packages/backend/src/nest/connections-manager/connections-manager.service.ts b/packages/backend/src/nest/connections-manager/connections-manager.service.ts index a9bb6fc35a..62d14cc95f 100644 --- a/packages/backend/src/nest/connections-manager/connections-manager.service.ts +++ b/packages/backend/src/nest/connections-manager/connections-manager.service.ts @@ -58,8 +58,8 @@ import { emitError } from '../socket/socket.errors' import { SocketService } from '../socket/socket.service' import { StorageService } from '../storage/storage.service' import { StorageEvents } from '../storage/storage.types' -import { ServerProxyService } from '../storageServerProxy/storageServerProxy.service' -import { ServerStoredCommunityMetadata } from '../storageServerProxy/storageServerProxy.types' +import { StorageServiceClient } from '../storageServiceClient/storageServiceClient.service' +import { ServerStoredCommunityMetadata } from '../storageServiceClient/storageServiceClient.types' import { Tor } from '../tor/tor.service' import { ConfigOptions, GetPorts, ServerIoProviderTypes } from '../types' import { ServiceState, TorInitState } from './connections-manager.types' @@ -80,7 +80,7 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI @Inject(SOCKS_PROXY_AGENT) public readonly socksProxyAgent: Agent, private readonly socketService: SocketService, private readonly registrationService: RegistrationService, - private readonly storageServerProxyService: ServerProxyService, + private readonly storageServerProxyService: StorageServiceClient, private readonly localDbService: LocalDbService, private readonly storageService: StorageService, private readonly tor: Tor, diff --git a/packages/backend/src/nest/storageServerProxy/storageServerProxy.module.ts b/packages/backend/src/nest/storageServerProxy/storageServerProxy.module.ts deleted file mode 100644 index 9fc2a49862..0000000000 --- a/packages/backend/src/nest/storageServerProxy/storageServerProxy.module.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Module } from '@nestjs/common' -import { ServerProxyService } from './storageServerProxy.service' - -@Module({ - providers: [ServerProxyService], - exports: [ServerProxyService], -}) -export class ServerProxyServiceModule {} diff --git a/packages/backend/src/nest/storageServiceClient/storageServiceClient.module.ts b/packages/backend/src/nest/storageServiceClient/storageServiceClient.module.ts new file mode 100644 index 0000000000..f0c8b849f4 --- /dev/null +++ b/packages/backend/src/nest/storageServiceClient/storageServiceClient.module.ts @@ -0,0 +1,8 @@ +import { Module } from '@nestjs/common' +import { StorageServiceClient } from './storageServiceClient.service' + +@Module({ + providers: [StorageServiceClient], + exports: [StorageServiceClient], +}) +export class StorageServiceClientModule {} diff --git a/packages/backend/src/nest/storageServerProxy/storageServerProxy.service.spec.ts b/packages/backend/src/nest/storageServiceClient/storageServiceClient.service.spec.ts similarity index 88% rename from packages/backend/src/nest/storageServerProxy/storageServerProxy.service.spec.ts rename to packages/backend/src/nest/storageServiceClient/storageServiceClient.service.spec.ts index 4187352e26..2494b356a1 100644 --- a/packages/backend/src/nest/storageServerProxy/storageServerProxy.service.spec.ts +++ b/packages/backend/src/nest/storageServiceClient/storageServiceClient.service.spec.ts @@ -1,7 +1,7 @@ import { Test } from '@nestjs/testing' -import { ServerProxyServiceModule } from './storageServerProxy.module' -import { ServerProxyService } from './storageServerProxy.service' -import { ServerStoredCommunityMetadata } from './storageServerProxy.types' +import { StorageServiceClientModule } from './storageServiceClient.module' +import { StorageServiceClient } from './storageServiceClient.service' +import { ServerStoredCommunityMetadata } from './storageServiceClient.types' import { jest } from '@jest/globals' import { prepareResponse } from './testUtils' import { createLibp2pAddress, getValidInvitationUrlTestData, validInvitationDatav1 } from '@quiet/common' @@ -18,14 +18,14 @@ const mockFetch = async (responseData: Partial[]) => { } const module = await Test.createTestingModule({ - imports: [ServerProxyServiceModule], + imports: [StorageServiceClientModule], }).compile() - const service = module.get(ServerProxyService) + const service = module.get(StorageServiceClient) service.fetch = mockedFetch return service } -describe('Server Proxy Service', () => { +describe('Storage Service Client', () => { let clientMetadata: ServerStoredCommunityMetadata beforeEach(() => { const data = getValidInvitationUrlTestData(validInvitationDatav1[0]).data diff --git a/packages/backend/src/nest/storageServerProxy/storageServerProxy.service.ts b/packages/backend/src/nest/storageServiceClient/storageServiceClient.service.ts similarity index 94% rename from packages/backend/src/nest/storageServerProxy/storageServerProxy.service.ts rename to packages/backend/src/nest/storageServiceClient/storageServiceClient.service.ts index e3c8f8aa90..482fdf9c82 100644 --- a/packages/backend/src/nest/storageServerProxy/storageServerProxy.service.ts +++ b/packages/backend/src/nest/storageServiceClient/storageServiceClient.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@nestjs/common' import EventEmitter from 'events' -import { ServerStoredCommunityMetadata } from './storageServerProxy.types' +import { ServerStoredCommunityMetadata } from './storageServiceClient.types' import fetchRetry, { RequestInitWithRetry } from 'fetch-retry' import Logger from '../common/logger' import { isServerStoredMetadata } from '../validation/validators' @@ -15,9 +15,9 @@ class HTTPResponseError extends Error { } @Injectable() -export class ServerProxyService extends EventEmitter { +export class StorageServiceClient extends EventEmitter { DEFAULT_FETCH_RETRIES = 5 - private readonly logger = Logger(ServerProxyService.name) + private readonly logger = Logger(StorageServiceClient.name) _serverAddress: string fetch: any fetchConfig: RequestInitWithRetry diff --git a/packages/backend/src/nest/storageServerProxy/storageServerProxy.types.ts b/packages/backend/src/nest/storageServiceClient/storageServiceClient.types.ts similarity index 100% rename from packages/backend/src/nest/storageServerProxy/storageServerProxy.types.ts rename to packages/backend/src/nest/storageServiceClient/storageServiceClient.types.ts diff --git a/packages/backend/src/nest/storageServerProxy/testUtils.ts b/packages/backend/src/nest/storageServiceClient/testUtils.ts similarity index 100% rename from packages/backend/src/nest/storageServerProxy/testUtils.ts rename to packages/backend/src/nest/storageServiceClient/testUtils.ts diff --git a/packages/backend/src/nest/validation/validators.ts b/packages/backend/src/nest/validation/validators.ts index fff7900123..d562af45b7 100644 --- a/packages/backend/src/nest/validation/validators.ts +++ b/packages/backend/src/nest/validation/validators.ts @@ -1,7 +1,7 @@ import _ from 'validator' import joi from 'joi' import { ChannelMessage, PublicChannel } from '@quiet/types' -import { ServerStoredCommunityMetadata } from '../storageServerProxy/storageServerProxy.types' +import { ServerStoredCommunityMetadata } from '../storageServiceClient/storageServiceClient.types' import { isPSKcodeValid } from '@quiet/common' const messageMediaSchema = joi.object({