Skip to content

Commit

Permalink
chore: refactor - rename server-handling service
Browse files Browse the repository at this point in the history
  • Loading branch information
EmiM committed Apr 23, 2024
1 parent c2dba47 commit db753f1
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Module } from '@nestjs/common'
import { StorageServiceClient } from './storageServiceClient.service'

@Module({
providers: [StorageServiceClient],
exports: [StorageServiceClient],
})
export class StorageServiceClientModule {}
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -18,14 +18,14 @@ const mockFetch = async (responseData: Partial<Response>[]) => {
}

const module = await Test.createTestingModule({
imports: [ServerProxyServiceModule],
imports: [StorageServiceClientModule],
}).compile()
const service = module.get<ServerProxyService>(ServerProxyService)
const service = module.get<StorageServiceClient>(StorageServiceClient)
service.fetch = mockedFetch
return service
}

describe('Server Proxy Service', () => {
describe('Storage Service Client', () => {
let clientMetadata: ServerStoredCommunityMetadata
beforeEach(() => {
const data = getValidInvitationUrlTestData(validInvitationDatav1[0]).data
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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<typeof fetch>
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/nest/validation/validators.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand Down

0 comments on commit db753f1

Please sign in to comment.