mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
refactor: move /server-info endpoints to /server (#10677)
This commit is contained in:
parent
e361640e39
commit
a2364a12cf
16 changed files with 867 additions and 41 deletions
|
|
@ -20,6 +20,7 @@ import { PartnerController } from 'src/controllers/partner.controller';
|
|||
import { PersonController } from 'src/controllers/person.controller';
|
||||
import { SearchController } from 'src/controllers/search.controller';
|
||||
import { ServerInfoController } from 'src/controllers/server-info.controller';
|
||||
import { ServerController } from 'src/controllers/server.controller';
|
||||
import { SessionController } from 'src/controllers/session.controller';
|
||||
import { SharedLinkController } from 'src/controllers/shared-link.controller';
|
||||
import { SyncController } from 'src/controllers/sync.controller';
|
||||
|
|
@ -53,6 +54,7 @@ export const controllers = [
|
|||
PersonController,
|
||||
ReportController,
|
||||
SearchController,
|
||||
ServerController,
|
||||
ServerInfoController,
|
||||
SessionController,
|
||||
SharedLinkController,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { Controller, Get } from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { EndpointLifecycle } from 'src/decorators';
|
||||
import {
|
||||
ServerAboutResponseDto,
|
||||
ServerConfigDto,
|
||||
|
|
@ -10,63 +11,72 @@ import {
|
|||
ServerStorageResponseDto,
|
||||
ServerThemeDto,
|
||||
ServerVersionResponseDto,
|
||||
} from 'src/dtos/server-info.dto';
|
||||
} from 'src/dtos/server.dto';
|
||||
import { Authenticated } from 'src/middleware/auth.guard';
|
||||
import { ServerInfoService } from 'src/services/server-info.service';
|
||||
import { ServerService } from 'src/services/server.service';
|
||||
import { VersionService } from 'src/services/version.service';
|
||||
|
||||
@ApiTags('Server Info')
|
||||
@Controller('server-info')
|
||||
export class ServerInfoController {
|
||||
constructor(
|
||||
private service: ServerInfoService,
|
||||
private service: ServerService,
|
||||
private versionService: VersionService,
|
||||
) {}
|
||||
|
||||
@Get('about')
|
||||
@EndpointLifecycle({ deprecatedAt: 'v1.107.0' })
|
||||
@Authenticated()
|
||||
getAboutInfo(): Promise<ServerAboutResponseDto> {
|
||||
return this.service.getAboutInfo();
|
||||
}
|
||||
|
||||
@Get('storage')
|
||||
@EndpointLifecycle({ deprecatedAt: 'v1.107.0' })
|
||||
@Authenticated()
|
||||
getStorage(): Promise<ServerStorageResponseDto> {
|
||||
return this.service.getStorage();
|
||||
}
|
||||
|
||||
@Get('ping')
|
||||
@EndpointLifecycle({ deprecatedAt: 'v1.107.0' })
|
||||
pingServer(): ServerPingResponse {
|
||||
return this.service.ping();
|
||||
}
|
||||
|
||||
@Get('version')
|
||||
@EndpointLifecycle({ deprecatedAt: 'v1.107.0' })
|
||||
getServerVersion(): ServerVersionResponseDto {
|
||||
return this.versionService.getVersion();
|
||||
}
|
||||
|
||||
@Get('features')
|
||||
@EndpointLifecycle({ deprecatedAt: 'v1.107.0' })
|
||||
getServerFeatures(): Promise<ServerFeaturesDto> {
|
||||
return this.service.getFeatures();
|
||||
}
|
||||
|
||||
@Get('theme')
|
||||
@EndpointLifecycle({ deprecatedAt: 'v1.107.0' })
|
||||
getTheme(): Promise<ServerThemeDto> {
|
||||
return this.service.getTheme();
|
||||
}
|
||||
|
||||
@Get('config')
|
||||
@EndpointLifecycle({ deprecatedAt: 'v1.107.0' })
|
||||
getServerConfig(): Promise<ServerConfigDto> {
|
||||
return this.service.getConfig();
|
||||
}
|
||||
|
||||
@Authenticated({ admin: true })
|
||||
@EndpointLifecycle({ deprecatedAt: 'v1.107.0' })
|
||||
@Get('statistics')
|
||||
getServerStatistics(): Promise<ServerStatsResponseDto> {
|
||||
return this.service.getStatistics();
|
||||
}
|
||||
|
||||
@Get('media-types')
|
||||
@EndpointLifecycle({ deprecatedAt: 'v1.107.0' })
|
||||
getSupportedMediaTypes(): ServerMediaTypesResponseDto {
|
||||
return this.service.getSupportedMediaTypes();
|
||||
}
|
||||
|
|
|
|||
82
server/src/controllers/server.controller.ts
Normal file
82
server/src/controllers/server.controller.ts
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
import { Controller, Get } from '@nestjs/common';
|
||||
import { ApiExcludeEndpoint, ApiTags } from '@nestjs/swagger';
|
||||
import {
|
||||
ServerAboutResponseDto,
|
||||
ServerConfigDto,
|
||||
ServerFeaturesDto,
|
||||
ServerMediaTypesResponseDto,
|
||||
ServerPingResponse,
|
||||
ServerStatsResponseDto,
|
||||
ServerStorageResponseDto,
|
||||
ServerThemeDto,
|
||||
ServerVersionResponseDto,
|
||||
} from 'src/dtos/server.dto';
|
||||
import { Authenticated } from 'src/middleware/auth.guard';
|
||||
import { ServerService } from 'src/services/server.service';
|
||||
import { VersionService } from 'src/services/version.service';
|
||||
|
||||
@ApiTags('Server')
|
||||
@Controller('server')
|
||||
export class ServerController {
|
||||
constructor(
|
||||
private service: ServerService,
|
||||
private versionService: VersionService,
|
||||
) {}
|
||||
|
||||
@Get('about')
|
||||
@Authenticated()
|
||||
@ApiExcludeEndpoint()
|
||||
getAboutInfo(): Promise<ServerAboutResponseDto> {
|
||||
return this.service.getAboutInfo();
|
||||
}
|
||||
|
||||
@Get('storage')
|
||||
@Authenticated()
|
||||
@ApiExcludeEndpoint()
|
||||
getStorage(): Promise<ServerStorageResponseDto> {
|
||||
return this.service.getStorage();
|
||||
}
|
||||
|
||||
@Get('ping')
|
||||
@ApiExcludeEndpoint()
|
||||
pingServer(): ServerPingResponse {
|
||||
return this.service.ping();
|
||||
}
|
||||
|
||||
@Get('version')
|
||||
@ApiExcludeEndpoint()
|
||||
getServerVersion(): ServerVersionResponseDto {
|
||||
return this.versionService.getVersion();
|
||||
}
|
||||
|
||||
@Get('features')
|
||||
@ApiExcludeEndpoint()
|
||||
getServerFeatures(): Promise<ServerFeaturesDto> {
|
||||
return this.service.getFeatures();
|
||||
}
|
||||
|
||||
@Get('theme')
|
||||
@ApiExcludeEndpoint()
|
||||
getTheme(): Promise<ServerThemeDto> {
|
||||
return this.service.getTheme();
|
||||
}
|
||||
|
||||
@Get('config')
|
||||
@ApiExcludeEndpoint()
|
||||
getServerConfig(): Promise<ServerConfigDto> {
|
||||
return this.service.getConfig();
|
||||
}
|
||||
|
||||
@Authenticated({ admin: true })
|
||||
@Get('statistics')
|
||||
@ApiExcludeEndpoint()
|
||||
getServerStatistics(): Promise<ServerStatsResponseDto> {
|
||||
return this.service.getStatistics();
|
||||
}
|
||||
|
||||
@Get('media-types')
|
||||
@ApiExcludeEndpoint()
|
||||
getSupportedMediaTypes(): ServerMediaTypesResponseDto {
|
||||
return this.service.getSupportedMediaTypes();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { SystemConfig } from 'src/config';
|
||||
import { AssetResponseDto } from 'src/dtos/asset-response.dto';
|
||||
import { ReleaseNotification, ServerVersionResponseDto } from 'src/dtos/server-info.dto';
|
||||
import { ReleaseNotification, ServerVersionResponseDto } from 'src/dtos/server.dto';
|
||||
|
||||
export const IEventRepository = 'IEventRepository';
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import { NotificationService } from 'src/services/notification.service';
|
|||
import { PartnerService } from 'src/services/partner.service';
|
||||
import { PersonService } from 'src/services/person.service';
|
||||
import { SearchService } from 'src/services/search.service';
|
||||
import { ServerInfoService } from 'src/services/server-info.service';
|
||||
import { ServerService } from 'src/services/server.service';
|
||||
import { SessionService } from 'src/services/session.service';
|
||||
import { SharedLinkService } from 'src/services/shared-link.service';
|
||||
import { SmartInfoService } from 'src/services/smart-info.service';
|
||||
|
|
@ -61,7 +61,7 @@ export const services = [
|
|||
PartnerService,
|
||||
PersonService,
|
||||
SearchService,
|
||||
ServerInfoService,
|
||||
ServerService,
|
||||
SessionService,
|
||||
SharedLinkService,
|
||||
SmartInfoService,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { IServerInfoRepository } from 'src/interfaces/server-info.interface';
|
|||
import { IStorageRepository } from 'src/interfaces/storage.interface';
|
||||
import { ISystemMetadataRepository } from 'src/interfaces/system-metadata.interface';
|
||||
import { IUserRepository } from 'src/interfaces/user.interface';
|
||||
import { ServerInfoService } from 'src/services/server-info.service';
|
||||
import { ServerService } from 'src/services/server.service';
|
||||
import { newLoggerRepositoryMock } from 'test/repositories/logger.repository.mock';
|
||||
import { newServerInfoRepositoryMock } from 'test/repositories/server-info.repository.mock';
|
||||
import { newStorageRepositoryMock } from 'test/repositories/storage.repository.mock';
|
||||
|
|
@ -11,8 +11,8 @@ import { newSystemMetadataRepositoryMock } from 'test/repositories/system-metada
|
|||
import { newUserRepositoryMock } from 'test/repositories/user.repository.mock';
|
||||
import { Mocked } from 'vitest';
|
||||
|
||||
describe(ServerInfoService.name, () => {
|
||||
let sut: ServerInfoService;
|
||||
describe(ServerService.name, () => {
|
||||
let sut: ServerService;
|
||||
let storageMock: Mocked<IStorageRepository>;
|
||||
let userMock: Mocked<IUserRepository>;
|
||||
let serverInfoMock: Mocked<IServerInfoRepository>;
|
||||
|
|
@ -26,7 +26,7 @@ describe(ServerInfoService.name, () => {
|
|||
systemMock = newSystemMetadataRepositoryMock();
|
||||
loggerMock = newLoggerRepositoryMock();
|
||||
|
||||
sut = new ServerInfoService(userMock, storageMock, systemMock, serverInfoMock, loggerMock);
|
||||
sut = new ServerService(userMock, storageMock, systemMock, serverInfoMock, loggerMock);
|
||||
});
|
||||
|
||||
it('should work', () => {
|
||||
|
|
@ -12,7 +12,7 @@ import {
|
|||
ServerStatsResponseDto,
|
||||
ServerStorageResponseDto,
|
||||
UsageByUserDto,
|
||||
} from 'src/dtos/server-info.dto';
|
||||
} from 'src/dtos/server.dto';
|
||||
import { SystemMetadataKey } from 'src/entities/system-metadata.entity';
|
||||
import { OnEvents } from 'src/interfaces/event.interface';
|
||||
import { ILoggerRepository } from 'src/interfaces/logger.interface';
|
||||
|
|
@ -25,7 +25,7 @@ import { mimeTypes } from 'src/utils/mime-types';
|
|||
import { isDuplicateDetectionEnabled, isFacialRecognitionEnabled, isSmartSearchEnabled } from 'src/utils/misc';
|
||||
|
||||
@Injectable()
|
||||
export class ServerInfoService implements OnEvents {
|
||||
export class ServerService implements OnEvents {
|
||||
private configCore: SystemConfigCore;
|
||||
|
||||
constructor(
|
||||
|
|
@ -35,7 +35,7 @@ export class ServerInfoService implements OnEvents {
|
|||
@Inject(IServerInfoRepository) private serverInfoRepository: IServerInfoRepository,
|
||||
@Inject(ILoggerRepository) private logger: ILoggerRepository,
|
||||
) {
|
||||
this.logger.setContext(ServerInfoService.name);
|
||||
this.logger.setContext(ServerService.name);
|
||||
this.configCore = SystemConfigCore.create(systemMetadataRepository, this.logger);
|
||||
}
|
||||
|
||||
|
|
@ -4,7 +4,7 @@ import semver, { SemVer } from 'semver';
|
|||
import { isDev, serverVersion } from 'src/constants';
|
||||
import { SystemConfigCore } from 'src/cores/system-config.core';
|
||||
import { OnServerEvent } from 'src/decorators';
|
||||
import { ReleaseNotification, ServerVersionResponseDto } from 'src/dtos/server-info.dto';
|
||||
import { ReleaseNotification, ServerVersionResponseDto } from 'src/dtos/server.dto';
|
||||
import { SystemMetadataKey, VersionCheckMetadata } from 'src/entities/system-metadata.entity';
|
||||
import { ClientEvent, IEventRepository, OnEvents, ServerEvent, ServerEventMap } from 'src/interfaces/event.interface';
|
||||
import { IJobRepository, JobName, JobStatus } from 'src/interfaces/job.interface';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue