Skip to content

Commit

Permalink
chore(server): move services (#8133)
Browse files Browse the repository at this point in the history
move services
  • Loading branch information
danieldietzler authored Mar 20, 2024
1 parent 6d9e769 commit ef4a492
Show file tree
Hide file tree
Showing 83 changed files with 104 additions and 100 deletions.
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@
"cSpell.words": [
"immich"
],
"explorer.fileNesting.enabled": true,
"explorer.fileNesting.patterns": {
"*.ts": "${capture}.spec.ts,${capture}.mock.ts"
}
}
2 changes: 1 addition & 1 deletion server/e2e/jobs/specs/library-watcher.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { api } from 'e2e/client';
import fs from 'node:fs/promises';
import path from 'node:path';
import { LibraryService } from 'src/domain/library/library.service';
import { LoginResponseDto } from 'src/dtos/auth.dto';
import { LibraryResponseDto } from 'src/dtos/library.dto';
import { AssetType } from 'src/entities/asset.entity';
import { LibraryType } from 'src/entities/library.entity';
import { StorageEventType } from 'src/interfaces/storage.repository';
import { LibraryService } from 'src/services/library.service';
import {
IMMICH_TEST_ASSET_PATH,
IMMICH_TEST_ASSET_TEMP_PATH,
Expand Down
14 changes: 7 additions & 7 deletions server/src/apps/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { Cron, CronExpression, Interval } from '@nestjs/schedule';
import { NextFunction, Request, Response } from 'express';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { AuthService } from 'src/domain/auth/auth.service';
import { DatabaseService } from 'src/domain/database/database.service';
import { ONE_HOUR, WEB_ROOT } from 'src/domain/domain.constant';
import { JobService } from 'src/domain/job/job.service';
import { ServerInfoService } from 'src/domain/server-info/server-info.service';
import { SharedLinkService } from 'src/domain/shared-link/shared-link.service';
import { StorageService } from 'src/domain/storage/storage.service';
import { SystemConfigService } from 'src/domain/system-config/system-config.service';
import { ImmichLogger } from 'src/infra/logger';
import { AuthService } from 'src/services/auth.service';
import { DatabaseService } from 'src/services/database.service';
import { JobService } from 'src/services/job.service';
import { ServerInfoService } from 'src/services/server-info.service';
import { SharedLinkService } from 'src/services/shared-link.service';
import { StorageService } from 'src/services/storage.service';
import { SystemConfigService } from 'src/services/system-config.service';
import { OpenGraphTags } from 'src/utils';

const render = (index: string, meta: OpenGraphTags) => {
Expand Down
48 changes: 24 additions & 24 deletions server/src/apps/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,6 @@ import { ScheduleModule, SchedulerRegistry } from '@nestjs/schedule';
import { TypeOrmModule } from '@nestjs/typeorm';
import { OpenTelemetryModule } from 'nestjs-otel';
import { bullConfig, bullQueues, immichAppConfig } from 'src/config';
import { ActivityService } from 'src/domain/activity/activity.service';
import { AlbumService } from 'src/domain/album/album.service';
import { APIKeyService } from 'src/domain/api-key/api-key.service';
import { AssetService } from 'src/domain/asset/asset.service';
import { AuditService } from 'src/domain/audit/audit.service';
import { AuthService } from 'src/domain/auth/auth.service';
import { DatabaseService } from 'src/domain/database/database.service';
import { DownloadService } from 'src/domain/download/download.service';
import { JobService } from 'src/domain/job/job.service';
import { LibraryService } from 'src/domain/library/library.service';
import { MediaService } from 'src/domain/media/media.service';
import { MetadataService } from 'src/domain/metadata/metadata.service';
import { PartnerService } from 'src/domain/partner/partner.service';
import { PersonService } from 'src/domain/person/person.service';
import { SearchService } from 'src/domain/search/search.service';
import { ServerInfoService } from 'src/domain/server-info/server-info.service';
import { SharedLinkService } from 'src/domain/shared-link/shared-link.service';
import { SmartInfoService } from 'src/domain/smart-info/smart-info.service';
import { StorageTemplateService } from 'src/domain/storage-template/storage-template.service';
import { StorageService } from 'src/domain/storage/storage.service';
import { SystemConfigService } from 'src/domain/system-config/system-config.service';
import { TagService } from 'src/domain/tag/tag.service';
import { TrashService } from 'src/domain/trash/trash.service';
import { UserService } from 'src/domain/user/user.service';
import { databaseEntities } from 'src/entities';
import { databaseConfig } from 'src/infra/database.config';
import { otelConfig } from 'src/infra/instrumentation';
Expand Down Expand Up @@ -88,6 +64,30 @@ import { SystemMetadataRepository } from 'src/repositories/system-metadata.repos
import { TagRepository } from 'src/repositories/tag.repository';
import { UserTokenRepository } from 'src/repositories/user-token.repository';
import { UserRepository } from 'src/repositories/user.repository';
import { ActivityService } from 'src/services/activity.service';
import { AlbumService } from 'src/services/album.service';
import { APIKeyService } from 'src/services/api-key.service';
import { AssetService } from 'src/services/asset.service';
import { AuditService } from 'src/services/audit.service';
import { AuthService } from 'src/services/auth.service';
import { DatabaseService } from 'src/services/database.service';
import { DownloadService } from 'src/services/download.service';
import { JobService } from 'src/services/job.service';
import { LibraryService } from 'src/services/library.service';
import { MediaService } from 'src/services/media.service';
import { MetadataService } from 'src/services/metadata.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 { SharedLinkService } from 'src/services/shared-link.service';
import { SmartInfoService } from 'src/services/smart-info.service';
import { StorageTemplateService } from 'src/services/storage-template.service';
import { StorageService } from 'src/services/storage.service';
import { SystemConfigService } from 'src/services/system-config.service';
import { TagService } from 'src/services/tag.service';
import { TrashService } from 'src/services/trash.service';
import { UserService } from 'src/services/user.service';

const services: Provider[] = [
APIKeyService,
Expand Down
26 changes: 13 additions & 13 deletions server/src/apps/microservices.service.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { Injectable } from '@nestjs/common';
import { AssetService } from 'src/domain/asset/asset.service';
import { AuditService } from 'src/domain/audit/audit.service';
import { DatabaseService } from 'src/domain/database/database.service';
import { JobName } from 'src/domain/job/job.constants';
import { IDeleteFilesJob } from 'src/domain/job/job.interface';
import { JobService } from 'src/domain/job/job.service';
import { LibraryService } from 'src/domain/library/library.service';
import { MediaService } from 'src/domain/media/media.service';
import { MetadataService } from 'src/domain/metadata/metadata.service';
import { PersonService } from 'src/domain/person/person.service';
import { SmartInfoService } from 'src/domain/smart-info/smart-info.service';
import { StorageTemplateService } from 'src/domain/storage-template/storage-template.service';
import { StorageService } from 'src/domain/storage/storage.service';
import { SystemConfigService } from 'src/domain/system-config/system-config.service';
import { UserService } from 'src/domain/user/user.service';
import { otelSDK } from 'src/infra/instrumentation';
import { AssetService } from 'src/services/asset.service';
import { AuditService } from 'src/services/audit.service';
import { DatabaseService } from 'src/services/database.service';
import { JobService } from 'src/services/job.service';
import { LibraryService } from 'src/services/library.service';
import { MediaService } from 'src/services/media.service';
import { MetadataService } from 'src/services/metadata.service';
import { PersonService } from 'src/services/person.service';
import { SmartInfoService } from 'src/services/smart-info.service';
import { StorageTemplateService } from 'src/services/storage-template.service';
import { StorageService } from 'src/services/storage.service';
import { SystemConfigService } from 'src/services/system-config.service';
import { UserService } from 'src/services/user.service';

@Injectable()
export class MicroservicesService {
Expand Down
2 changes: 1 addition & 1 deletion server/src/commands/list-users.command.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Command, CommandRunner } from 'nest-commander';
import { UserService } from 'src/domain/user/user.service';
import { UserEntity } from 'src/entities/user.entity';
import { UserService } from 'src/services/user.service';

@Command({
name: 'list-users',
Expand Down
2 changes: 1 addition & 1 deletion server/src/commands/oauth-login.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command, CommandRunner } from 'nest-commander';
import { SystemConfigService } from 'src/domain/system-config/system-config.service';
import { SystemConfigService } from 'src/services/system-config.service';

@Command({
name: 'enable-oauth-login',
Expand Down
2 changes: 1 addition & 1 deletion server/src/commands/password-login.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command, CommandRunner } from 'nest-commander';
import { SystemConfigService } from 'src/domain/system-config/system-config.service';
import { SystemConfigService } from 'src/services/system-config.service';

@Command({
name: 'enable-password-login',
Expand Down
2 changes: 1 addition & 1 deletion server/src/commands/reset-admin-password.command.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Command, CommandRunner, InquirerService, Question, QuestionSet } from 'nest-commander';
import { UserService } from 'src/domain/user/user.service';
import { UserResponseDto } from 'src/dtos/user.dto';
import { UserService } from 'src/services/user.service';

@Command({
name: 'reset-admin-password',
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/activity.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Query, Res } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { Response } from 'express';
import { ActivityService } from 'src/domain/activity/activity.service';
import {
ActivityCreateDto,
ActivityDto,
Expand All @@ -11,6 +10,7 @@ import {
} from 'src/dtos/activity.dto';
import { AuthDto } from 'src/dtos/auth.dto';
import { Auth, Authenticated } from 'src/middleware/auth.guard';
import { ActivityService } from 'src/services/activity.service';
import { UUIDParamDto } from 'src/validation';

@ApiTags('Activity')
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/album.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Body, Controller, Delete, Get, Param, Patch, Post, Put, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { AlbumService } from 'src/domain/album/album.service';
import {
AddUsersDto,
AlbumCountResponseDto,
Expand All @@ -13,6 +12,7 @@ import {
import { BulkIdResponseDto, BulkIdsDto } from 'src/dtos/asset-ids.response.dto';
import { AuthDto } from 'src/dtos/auth.dto';
import { Auth, Authenticated, SharedLinkRoute } from 'src/middleware/auth.guard';
import { AlbumService } from 'src/services/album.service';
import { ParseMeUUIDPipe, UUIDParamDto } from 'src/validation';

@ApiTags('Album')
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/api-key.controller.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Body, Controller, Delete, Get, Param, Post, Put } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { APIKeyService } from 'src/domain/api-key/api-key.service';
import { APIKeyCreateDto, APIKeyCreateResponseDto, APIKeyResponseDto, APIKeyUpdateDto } from 'src/dtos/api-key.dto';
import { AuthDto } from 'src/dtos/auth.dto';
import { Auth, Authenticated } from 'src/middleware/auth.guard';
import { APIKeyService } from 'src/services/api-key.service';
import { UUIDParamDto } from 'src/validation';

@ApiTags('API Key')
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Controller, Get, Header } from '@nestjs/common';
import { ApiExcludeEndpoint } from '@nestjs/swagger';
import { SystemConfigService } from 'src/domain/system-config/system-config.service';
import { PublicRoute } from 'src/middleware/auth.guard';
import { SystemConfigService } from 'src/services/system-config.service';

@Controller()
export class AppController {
Expand Down
4 changes: 2 additions & 2 deletions server/src/controllers/asset.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Put, Query } from '@nestjs/common';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { AssetService } from 'src/domain/asset/asset.service';
import { SearchService } from 'src/domain/search/search.service';
import { AssetResponseDto, MemoryLaneResponseDto } from 'src/dtos/asset-response.dto';
import {
AssetBulkDeleteDto,
Expand All @@ -19,6 +17,8 @@ import { UpdateStackParentDto } from 'src/dtos/stack.dto';
import { TimeBucketAssetDto, TimeBucketDto, TimeBucketResponseDto } from 'src/dtos/time-bucket.dto';
import { Auth, Authenticated, SharedLinkRoute } from 'src/middleware/auth.guard';
import { Route } from 'src/middleware/file-upload.interceptor';
import { AssetService } from 'src/services/asset.service';
import { SearchService } from 'src/services/search.service';
import { UUIDParamDto } from 'src/validation';

@ApiTags('Asset')
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/audit.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Body, Controller, Get, Post, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { AuditService } from 'src/domain/audit/audit.service';
import {
AuditDeletesDto,
AuditDeletesResponseDto,
Expand All @@ -11,6 +10,7 @@ import {
} from 'src/dtos/audit.dto';
import { AuthDto } from 'src/dtos/auth.dto';
import { AdminRoute, Auth, Authenticated } from 'src/middleware/auth.guard';
import { AuditService } from 'src/services/audit.service';

@ApiTags('Audit')
@Controller('audit')
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Req,
import { ApiTags } from '@nestjs/swagger';
import { Request, Response } from 'express';
import { IMMICH_ACCESS_COOKIE, IMMICH_AUTH_TYPE_COOKIE, IMMICH_IS_AUTHENTICATED } from 'src/domain/auth/auth.constant';
import { AuthService, LoginDetails } from 'src/domain/auth/auth.service';
import {
AuthDeviceResponseDto,
AuthDto,
Expand All @@ -15,6 +14,7 @@ import {
} from 'src/dtos/auth.dto';
import { UserResponseDto, mapUser } from 'src/dtos/user.dto';
import { Auth, Authenticated, GetLoginDetails, PublicRoute } from 'src/middleware/auth.guard';
import { AuthService, LoginDetails } from 'src/services/auth.service';
import { UUIDParamDto } from 'src/validation';

@ApiTags('Authentication')
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/download.controller.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Body, Controller, HttpCode, HttpStatus, Next, Param, Post, Res, StreamableFile } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { NextFunction, Response } from 'express';
import { DownloadService } from 'src/domain/download/download.service';
import { AssetIdsDto } from 'src/dtos/asset.dto';
import { AuthDto } from 'src/dtos/auth.dto';
import { DownloadInfoDto, DownloadResponseDto } from 'src/dtos/download.dto';
import { asStreamableFile, sendFile } from 'src/immich/app.utils';
import { Auth, Authenticated, FileResponse, SharedLinkRoute } from 'src/middleware/auth.guard';
import { DownloadService } from 'src/services/download.service';
import { UUIDParamDto } from 'src/validation';

@ApiTags('Download')
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/face.controller.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Body, Controller, Get, Param, Put, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { PersonService } from 'src/domain/person/person.service';
import { AuthDto } from 'src/dtos/auth.dto';
import { AssetFaceResponseDto, FaceDto, PersonResponseDto } from 'src/dtos/person.dto';
import { Auth, Authenticated } from 'src/middleware/auth.guard';
import { PersonService } from 'src/services/person.service';
import { UUIDParamDto } from 'src/validation';

@ApiTags('Face')
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/job.controller.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Body, Controller, Get, Param, Put } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { JobService } from 'src/domain/job/job.service';
import { AllJobStatusResponseDto, JobCommandDto, JobIdParamDto, JobStatusDto } from 'src/dtos/job.dto';
import { Authenticated } from 'src/middleware/auth.guard';
import { JobService } from 'src/services/job.service';

@ApiTags('Job')
@Controller('jobs')
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/library.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Put, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { LibraryService } from 'src/domain/library/library.service';
import {
CreateLibraryDto,
LibraryResponseDto,
Expand All @@ -12,6 +11,7 @@ import {
ValidateLibraryResponseDto,
} from 'src/dtos/library.dto';
import { AdminRoute, Authenticated } from 'src/middleware/auth.guard';
import { LibraryService } from 'src/services/library.service';
import { UUIDParamDto } from 'src/validation';

@ApiTags('Library')
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/oauth.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Body, Controller, Get, HttpStatus, Post, Redirect, Req, Res } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { Request, Response } from 'express';
import { AuthService, LoginDetails } from 'src/domain/auth/auth.service';
import {
AuthDto,
LoginResponseDto,
Expand All @@ -11,6 +10,7 @@ import {
} from 'src/dtos/auth.dto';
import { UserResponseDto } from 'src/dtos/user.dto';
import { Auth, Authenticated, GetLoginDetails, PublicRoute } from 'src/middleware/auth.guard';
import { AuthService, LoginDetails } from 'src/services/auth.service';

@ApiTags('OAuth')
@Controller('oauth')
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/partner.controller.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Body, Controller, Delete, Get, Param, Post, Put, Query } from '@nestjs/common';
import { ApiQuery, ApiTags } from '@nestjs/swagger';
import { PartnerService } from 'src/domain/partner/partner.service';
import { AuthDto } from 'src/dtos/auth.dto';
import { PartnerResponseDto, UpdatePartnerDto } from 'src/dtos/partner.dto';
import { PartnerDirection } from 'src/interfaces/partner.repository';
import { Auth, Authenticated } from 'src/middleware/auth.guard';
import { PartnerService } from 'src/services/partner.service';
import { UUIDParamDto } from 'src/validation';

@ApiTags('Partner')
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/person.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Body, Controller, Get, Next, Param, Post, Put, Query, Res } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { NextFunction, Response } from 'express';
import { PersonService } from 'src/domain/person/person.service';
import { BulkIdResponseDto } from 'src/dtos/asset-ids.response.dto';
import { AssetResponseDto } from 'src/dtos/asset-response.dto';
import { AuthDto } from 'src/dtos/auth.dto';
Expand All @@ -18,6 +17,7 @@ import {
} from 'src/dtos/person.dto';
import { sendFile } from 'src/immich/app.utils';
import { Auth, Authenticated, FileResponse } from 'src/middleware/auth.guard';
import { PersonService } from 'src/services/person.service';
import { UUIDParamDto } from 'src/validation';

@ApiTags('Person')
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/search.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Body, Controller, Get, HttpCode, HttpStatus, Post, Query } from '@nestjs/common';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { SearchService } from 'src/domain/search/search.service';
import { AssetResponseDto } from 'src/dtos/asset-response.dto';
import { AuthDto } from 'src/dtos/auth.dto';
import { PersonResponseDto } from 'src/dtos/person.dto';
Expand All @@ -16,6 +15,7 @@ import {
SmartSearchDto,
} from 'src/dtos/search.dto';
import { Auth, Authenticated } from 'src/middleware/auth.guard';
import { SearchService } from 'src/services/search.service';

@ApiTags('Search')
@Controller('search')
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/server-info.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Controller, Get, HttpCode, HttpStatus, Post } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { ServerInfoService } from 'src/domain/server-info/server-info.service';
import {
ServerConfigDto,
ServerFeaturesDto,
Expand All @@ -12,6 +11,7 @@ import {
ServerVersionResponseDto,
} from 'src/dtos/server-info.dto';
import { AdminRoute, Authenticated, PublicRoute } from 'src/middleware/auth.guard';
import { ServerInfoService } from 'src/services/server-info.service';

@ApiTags('Server Info')
@Controller('server-info')
Expand Down
Loading

0 comments on commit ef4a492

Please sign in to comment.