From 40e079a247f29dedb7d3e55a7b7954a873300d28 Mon Sep 17 00:00:00 2001
From: Jason Rasmussen <jrasm91@gmail.com>
Date: Wed, 20 Mar 2024 15:15:01 -0500
Subject: [PATCH] chore: move controllers and middleware (#8119)

---
 server/e2e/jobs/specs/library.e2e-spec.ts     |  2 +-
 .../controllers/activity.controller.ts        |  2 +-
 .../controllers/album.controller.ts           |  2 +-
 .../controllers/api-key.controller.ts         |  2 +-
 .../controllers/app.controller.ts             |  2 +-
 .../controllers/asset.controller.ts           |  4 +-
 .../controllers/audit.controller.ts           |  2 +-
 .../controllers/auth.controller.ts            |  2 +-
 .../controllers/download.controller.ts        |  2 +-
 .../controllers/face.controller.ts            |  2 +-
 .../controllers/job.controller.ts             |  2 +-
 .../controllers/library.controller.ts         |  2 +-
 .../controllers/oauth.controller.ts           |  2 +-
 .../controllers/partner.controller.ts         |  2 +-
 .../controllers/person.controller.ts          |  2 +-
 .../controllers/search.controller.ts          |  2 +-
 .../controllers/server-info.controller.ts     |  2 +-
 .../controllers/shared-link.controller.ts     |  2 +-
 .../controllers/system-config.controller.ts   |  2 +-
 .../controllers/tag.controller.ts             |  2 +-
 .../controllers/trash.controller.ts           |  2 +-
 .../controllers/user.controller.ts            |  4 +-
 .../immich/api-v1/asset/asset.controller.ts   |  9 +---
 server/src/immich/app.module.ts               | 50 +++++++++----------
 server/src/immich/app.utils.ts                |  2 +-
 .../app.guard.ts => middleware/auth.guard.ts} |  4 +-
 .../error.interceptor.ts                      |  0
 .../file-upload.interceptor.ts                |  2 +-
 28 files changed, 55 insertions(+), 60 deletions(-)
 rename server/src/{immich => }/controllers/activity.controller.ts (95%)
 rename server/src/{immich => }/controllers/album.controller.ts (97%)
 rename server/src/{immich => }/controllers/api-key.controller.ts (95%)
 rename server/src/{immich => }/controllers/app.controller.ts (91%)
 rename server/src/{immich => }/controllers/asset.controller.ts (96%)
 rename server/src/{immich => }/controllers/audit.controller.ts (93%)
 rename server/src/{immich => }/controllers/auth.controller.ts (98%)
 rename server/src/{immich => }/controllers/download.controller.ts (98%)
 rename server/src/{immich => }/controllers/face.controller.ts (93%)
 rename server/src/{immich => }/controllers/job.controller.ts (92%)
 rename server/src/{immich => }/controllers/library.controller.ts (96%)
 rename server/src/{immich => }/controllers/oauth.controller.ts (98%)
 rename server/src/{immich => }/controllers/partner.controller.ts (95%)
 rename server/src/{immich => }/controllers/person.controller.ts (97%)
 rename server/src/{immich => }/controllers/search.controller.ts (97%)
 rename server/src/{immich => }/controllers/server-info.controller.ts (95%)
 rename server/src/{immich => }/controllers/shared-link.controller.ts (97%)
 rename server/src/{immich => }/controllers/system-config.controller.ts (94%)
 rename server/src/{immich => }/controllers/tag.controller.ts (97%)
 rename server/src/{immich => }/controllers/trash.controller.ts (93%)
 rename server/src/{immich => }/controllers/user.controller.ts (96%)
 rename server/src/{immich/app.guard.ts => middleware/auth.guard.ts} (97%)
 rename server/src/{immich/interceptors => middleware}/error.interceptor.ts (100%)
 rename server/src/{immich/interceptors => middleware}/file-upload.interceptor.ts (98%)

diff --git a/server/e2e/jobs/specs/library.e2e-spec.ts b/server/e2e/jobs/specs/library.e2e-spec.ts
index 24d7a620b6..f67dd91782 100644
--- a/server/e2e/jobs/specs/library.e2e-spec.ts
+++ b/server/e2e/jobs/specs/library.e2e-spec.ts
@@ -1,7 +1,7 @@
 import { api } from 'e2e/client';
 import fs from 'node:fs';
+import { LibraryController } from 'src/controllers/library.controller';
 import { LoginResponseDto } from 'src/domain/auth/auth.dto';
-import { LibraryController } from 'src/immich/controllers/library.controller';
 import { LibraryType } from 'src/infra/entities/library.entity';
 import { IMMICH_TEST_ASSET_PATH, IMMICH_TEST_ASSET_TEMP_PATH, restoreTempFolder, testApp } from 'src/test-utils/utils';
 import request from 'supertest';
diff --git a/server/src/immich/controllers/activity.controller.ts b/server/src/controllers/activity.controller.ts
similarity index 95%
rename from server/src/immich/controllers/activity.controller.ts
rename to server/src/controllers/activity.controller.ts
index 45f58e9f24..c405b0c6f5 100644
--- a/server/src/immich/controllers/activity.controller.ts
+++ b/server/src/controllers/activity.controller.ts
@@ -10,7 +10,7 @@ import {
 } from 'src/domain/activity/activity.dto';
 import { ActivityService } from 'src/domain/activity/activity.service';
 import { AuthDto } from 'src/domain/auth/auth.dto';
-import { Auth, Authenticated } from 'src/immich/app.guard';
+import { Auth, Authenticated } from 'src/middleware/auth.guard';
 import { UUIDParamDto } from 'src/validation';
 
 @ApiTags('Activity')
diff --git a/server/src/immich/controllers/album.controller.ts b/server/src/controllers/album.controller.ts
similarity index 97%
rename from server/src/immich/controllers/album.controller.ts
rename to server/src/controllers/album.controller.ts
index 12e35a0f6d..18fd549b6e 100644
--- a/server/src/immich/controllers/album.controller.ts
+++ b/server/src/controllers/album.controller.ts
@@ -9,7 +9,7 @@ import { AlbumInfoDto } from 'src/domain/album/dto/album.dto';
 import { GetAlbumsDto } from 'src/domain/album/dto/get-albums.dto';
 import { BulkIdResponseDto, BulkIdsDto } from 'src/domain/asset/response-dto/asset-ids-response.dto';
 import { AuthDto } from 'src/domain/auth/auth.dto';
-import { Auth, Authenticated, SharedLinkRoute } from 'src/immich/app.guard';
+import { Auth, Authenticated, SharedLinkRoute } from 'src/middleware/auth.guard';
 import { ParseMeUUIDPipe, UUIDParamDto } from 'src/validation';
 
 @ApiTags('Album')
diff --git a/server/src/immich/controllers/api-key.controller.ts b/server/src/controllers/api-key.controller.ts
similarity index 95%
rename from server/src/immich/controllers/api-key.controller.ts
rename to server/src/controllers/api-key.controller.ts
index 96afe676dd..2d4f8db155 100644
--- a/server/src/immich/controllers/api-key.controller.ts
+++ b/server/src/controllers/api-key.controller.ts
@@ -8,7 +8,7 @@ import {
 } from 'src/domain/api-key/api-key.dto';
 import { APIKeyService } from 'src/domain/api-key/api-key.service';
 import { AuthDto } from 'src/domain/auth/auth.dto';
-import { Auth, Authenticated } from 'src/immich/app.guard';
+import { Auth, Authenticated } from 'src/middleware/auth.guard';
 import { UUIDParamDto } from 'src/validation';
 
 @ApiTags('API Key')
diff --git a/server/src/immich/controllers/app.controller.ts b/server/src/controllers/app.controller.ts
similarity index 91%
rename from server/src/immich/controllers/app.controller.ts
rename to server/src/controllers/app.controller.ts
index 0e916cd25e..d4c7ea5b48 100644
--- a/server/src/immich/controllers/app.controller.ts
+++ b/server/src/controllers/app.controller.ts
@@ -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/immich/app.guard';
+import { PublicRoute } from 'src/middleware/auth.guard';
 
 @Controller()
 export class AppController {
diff --git a/server/src/immich/controllers/asset.controller.ts b/server/src/controllers/asset.controller.ts
similarity index 96%
rename from server/src/immich/controllers/asset.controller.ts
rename to server/src/controllers/asset.controller.ts
index ee35c98ddc..a6db598156 100644
--- a/server/src/immich/controllers/asset.controller.ts
+++ b/server/src/controllers/asset.controller.ts
@@ -20,8 +20,8 @@ import { TimeBucketResponseDto } from 'src/domain/asset/response-dto/time-bucket
 import { AuthDto } from 'src/domain/auth/auth.dto';
 import { MetadataSearchDto } from 'src/domain/search/dto/search.dto';
 import { SearchService } from 'src/domain/search/search.service';
-import { Auth, Authenticated, SharedLinkRoute } from 'src/immich/app.guard';
-import { Route } from 'src/immich/interceptors/file-upload.interceptor';
+import { Auth, Authenticated, SharedLinkRoute } from 'src/middleware/auth.guard';
+import { Route } from 'src/middleware/file-upload.interceptor';
 import { UUIDParamDto } from 'src/validation';
 
 @ApiTags('Asset')
diff --git a/server/src/immich/controllers/audit.controller.ts b/server/src/controllers/audit.controller.ts
similarity index 93%
rename from server/src/immich/controllers/audit.controller.ts
rename to server/src/controllers/audit.controller.ts
index 468257d26e..bb92f990e7 100644
--- a/server/src/immich/controllers/audit.controller.ts
+++ b/server/src/controllers/audit.controller.ts
@@ -10,7 +10,7 @@ import {
 } from 'src/domain/audit/audit.dto';
 import { AuditService } from 'src/domain/audit/audit.service';
 import { AuthDto } from 'src/domain/auth/auth.dto';
-import { AdminRoute, Auth, Authenticated } from 'src/immich/app.guard';
+import { AdminRoute, Auth, Authenticated } from 'src/middleware/auth.guard';
 
 @ApiTags('Audit')
 @Controller('audit')
diff --git a/server/src/immich/controllers/auth.controller.ts b/server/src/controllers/auth.controller.ts
similarity index 98%
rename from server/src/immich/controllers/auth.controller.ts
rename to server/src/controllers/auth.controller.ts
index 7f9fea47cf..941002fe64 100644
--- a/server/src/immich/controllers/auth.controller.ts
+++ b/server/src/controllers/auth.controller.ts
@@ -14,7 +14,7 @@ import {
 } from 'src/domain/auth/auth.dto';
 import { AuthService, LoginDetails } from 'src/domain/auth/auth.service';
 import { UserResponseDto, mapUser } from 'src/domain/user/response-dto/user-response.dto';
-import { Auth, Authenticated, GetLoginDetails, PublicRoute } from 'src/immich/app.guard';
+import { Auth, Authenticated, GetLoginDetails, PublicRoute } from 'src/middleware/auth.guard';
 import { UUIDParamDto } from 'src/validation';
 
 @ApiTags('Authentication')
diff --git a/server/src/immich/controllers/download.controller.ts b/server/src/controllers/download.controller.ts
similarity index 98%
rename from server/src/immich/controllers/download.controller.ts
rename to server/src/controllers/download.controller.ts
index 0cfaa3ea80..0fb3520cfe 100644
--- a/server/src/immich/controllers/download.controller.ts
+++ b/server/src/controllers/download.controller.ts
@@ -5,8 +5,8 @@ import { AssetIdsDto } from 'src/domain/asset/dto/asset-ids.dto';
 import { AuthDto } from 'src/domain/auth/auth.dto';
 import { DownloadInfoDto, DownloadResponseDto } from 'src/domain/download/download.dto';
 import { DownloadService } from 'src/domain/download/download.service';
-import { Auth, Authenticated, FileResponse, SharedLinkRoute } from 'src/immich/app.guard';
 import { asStreamableFile, sendFile } from 'src/immich/app.utils';
+import { Auth, Authenticated, FileResponse, SharedLinkRoute } from 'src/middleware/auth.guard';
 import { UUIDParamDto } from 'src/validation';
 
 @ApiTags('Download')
diff --git a/server/src/immich/controllers/face.controller.ts b/server/src/controllers/face.controller.ts
similarity index 93%
rename from server/src/immich/controllers/face.controller.ts
rename to server/src/controllers/face.controller.ts
index e7d1c3fba8..c7caba0161 100644
--- a/server/src/immich/controllers/face.controller.ts
+++ b/server/src/controllers/face.controller.ts
@@ -3,7 +3,7 @@ import { ApiTags } from '@nestjs/swagger';
 import { AuthDto } from 'src/domain/auth/auth.dto';
 import { AssetFaceResponseDto, FaceDto, PersonResponseDto } from 'src/domain/person/person.dto';
 import { PersonService } from 'src/domain/person/person.service';
-import { Auth, Authenticated } from 'src/immich/app.guard';
+import { Auth, Authenticated } from 'src/middleware/auth.guard';
 import { UUIDParamDto } from 'src/validation';
 
 @ApiTags('Face')
diff --git a/server/src/immich/controllers/job.controller.ts b/server/src/controllers/job.controller.ts
similarity index 92%
rename from server/src/immich/controllers/job.controller.ts
rename to server/src/controllers/job.controller.ts
index e5a8aac540..f0e9ed2be8 100644
--- a/server/src/immich/controllers/job.controller.ts
+++ b/server/src/controllers/job.controller.ts
@@ -2,7 +2,7 @@ import { Body, Controller, Get, Param, Put } from '@nestjs/common';
 import { ApiTags } from '@nestjs/swagger';
 import { AllJobStatusResponseDto, JobCommandDto, JobIdParamDto, JobStatusDto } from 'src/domain/job/job.dto';
 import { JobService } from 'src/domain/job/job.service';
-import { Authenticated } from 'src/immich/app.guard';
+import { Authenticated } from 'src/middleware/auth.guard';
 
 @ApiTags('Job')
 @Controller('jobs')
diff --git a/server/src/immich/controllers/library.controller.ts b/server/src/controllers/library.controller.ts
similarity index 96%
rename from server/src/immich/controllers/library.controller.ts
rename to server/src/controllers/library.controller.ts
index 5e362f6d0c..677773f2dc 100644
--- a/server/src/immich/controllers/library.controller.ts
+++ b/server/src/controllers/library.controller.ts
@@ -11,7 +11,7 @@ import {
   ValidateLibraryResponseDto,
 } from 'src/domain/library/library.dto';
 import { LibraryService } from 'src/domain/library/library.service';
-import { AdminRoute, Authenticated } from 'src/immich/app.guard';
+import { AdminRoute, Authenticated } from 'src/middleware/auth.guard';
 import { UUIDParamDto } from 'src/validation';
 
 @ApiTags('Library')
diff --git a/server/src/immich/controllers/oauth.controller.ts b/server/src/controllers/oauth.controller.ts
similarity index 98%
rename from server/src/immich/controllers/oauth.controller.ts
rename to server/src/controllers/oauth.controller.ts
index 8d7ce9478f..48b3eafd5e 100644
--- a/server/src/immich/controllers/oauth.controller.ts
+++ b/server/src/controllers/oauth.controller.ts
@@ -10,7 +10,7 @@ import {
 } from 'src/domain/auth/auth.dto';
 import { AuthService, LoginDetails } from 'src/domain/auth/auth.service';
 import { UserResponseDto } from 'src/domain/user/response-dto/user-response.dto';
-import { Auth, Authenticated, GetLoginDetails, PublicRoute } from 'src/immich/app.guard';
+import { Auth, Authenticated, GetLoginDetails, PublicRoute } from 'src/middleware/auth.guard';
 
 @ApiTags('OAuth')
 @Controller('oauth')
diff --git a/server/src/immich/controllers/partner.controller.ts b/server/src/controllers/partner.controller.ts
similarity index 95%
rename from server/src/immich/controllers/partner.controller.ts
rename to server/src/controllers/partner.controller.ts
index c6bfea3557..b756ade3e3 100644
--- a/server/src/immich/controllers/partner.controller.ts
+++ b/server/src/controllers/partner.controller.ts
@@ -4,7 +4,7 @@ import { AuthDto } from 'src/domain/auth/auth.dto';
 import { PartnerResponseDto, UpdatePartnerDto } from 'src/domain/partner/partner.dto';
 import { PartnerService } from 'src/domain/partner/partner.service';
 import { PartnerDirection } from 'src/domain/repositories/partner.repository';
-import { Auth, Authenticated } from 'src/immich/app.guard';
+import { Auth, Authenticated } from 'src/middleware/auth.guard';
 import { UUIDParamDto } from 'src/validation';
 
 @ApiTags('Partner')
diff --git a/server/src/immich/controllers/person.controller.ts b/server/src/controllers/person.controller.ts
similarity index 97%
rename from server/src/immich/controllers/person.controller.ts
rename to server/src/controllers/person.controller.ts
index 9ef791c3c9..bc955fd2c2 100644
--- a/server/src/immich/controllers/person.controller.ts
+++ b/server/src/controllers/person.controller.ts
@@ -16,8 +16,8 @@ import {
   PersonUpdateDto,
 } from 'src/domain/person/person.dto';
 import { PersonService } from 'src/domain/person/person.service';
-import { Auth, Authenticated, FileResponse } from 'src/immich/app.guard';
 import { sendFile } from 'src/immich/app.utils';
+import { Auth, Authenticated, FileResponse } from 'src/middleware/auth.guard';
 import { UUIDParamDto } from 'src/validation';
 
 @ApiTags('Person')
diff --git a/server/src/immich/controllers/search.controller.ts b/server/src/controllers/search.controller.ts
similarity index 97%
rename from server/src/immich/controllers/search.controller.ts
rename to server/src/controllers/search.controller.ts
index 4f8f19fd80..76fce16096 100644
--- a/server/src/immich/controllers/search.controller.ts
+++ b/server/src/controllers/search.controller.ts
@@ -15,7 +15,7 @@ import {
 import { SearchExploreResponseDto } from 'src/domain/search/response-dto/search-explore.response.dto';
 import { SearchResponseDto } from 'src/domain/search/response-dto/search-response.dto';
 import { SearchService } from 'src/domain/search/search.service';
-import { Auth, Authenticated } from 'src/immich/app.guard';
+import { Auth, Authenticated } from 'src/middleware/auth.guard';
 
 @ApiTags('Search')
 @Controller('search')
diff --git a/server/src/immich/controllers/server-info.controller.ts b/server/src/controllers/server-info.controller.ts
similarity index 95%
rename from server/src/immich/controllers/server-info.controller.ts
rename to server/src/controllers/server-info.controller.ts
index 5ff3de55ef..aae6174937 100644
--- a/server/src/immich/controllers/server-info.controller.ts
+++ b/server/src/controllers/server-info.controller.ts
@@ -11,7 +11,7 @@ import {
   ServerVersionResponseDto,
 } from 'src/domain/server-info/server-info.dto';
 import { ServerInfoService } from 'src/domain/server-info/server-info.service';
-import { AdminRoute, Authenticated, PublicRoute } from 'src/immich/app.guard';
+import { AdminRoute, Authenticated, PublicRoute } from 'src/middleware/auth.guard';
 
 @ApiTags('Server Info')
 @Controller('server-info')
diff --git a/server/src/immich/controllers/shared-link.controller.ts b/server/src/controllers/shared-link.controller.ts
similarity index 97%
rename from server/src/immich/controllers/shared-link.controller.ts
rename to server/src/controllers/shared-link.controller.ts
index b0717026c4..1e03a5c427 100644
--- a/server/src/immich/controllers/shared-link.controller.ts
+++ b/server/src/controllers/shared-link.controller.ts
@@ -8,7 +8,7 @@ import { AuthDto } from 'src/domain/auth/auth.dto';
 import { SharedLinkResponseDto } from 'src/domain/shared-link/shared-link-response.dto';
 import { SharedLinkCreateDto, SharedLinkEditDto, SharedLinkPasswordDto } from 'src/domain/shared-link/shared-link.dto';
 import { SharedLinkService } from 'src/domain/shared-link/shared-link.service';
-import { Auth, Authenticated, SharedLinkRoute } from 'src/immich/app.guard';
+import { Auth, Authenticated, SharedLinkRoute } from 'src/middleware/auth.guard';
 import { UUIDParamDto } from 'src/validation';
 
 @ApiTags('Shared Link')
diff --git a/server/src/immich/controllers/system-config.controller.ts b/server/src/controllers/system-config.controller.ts
similarity index 94%
rename from server/src/immich/controllers/system-config.controller.ts
rename to server/src/controllers/system-config.controller.ts
index 6d1ea8f1d6..d10bccee05 100644
--- a/server/src/immich/controllers/system-config.controller.ts
+++ b/server/src/controllers/system-config.controller.ts
@@ -4,7 +4,7 @@ import { SystemConfigDto } from 'src/domain/system-config/dto/system-config.dto'
 import { SystemConfigTemplateStorageOptionDto } from 'src/domain/system-config/response-dto/system-config-template-storage-option.dto';
 import { MapThemeDto } from 'src/domain/system-config/system-config-map-theme.dto';
 import { SystemConfigService } from 'src/domain/system-config/system-config.service';
-import { AdminRoute, Authenticated } from 'src/immich/app.guard';
+import { AdminRoute, Authenticated } from 'src/middleware/auth.guard';
 
 @ApiTags('System Config')
 @Controller('system-config')
diff --git a/server/src/immich/controllers/tag.controller.ts b/server/src/controllers/tag.controller.ts
similarity index 97%
rename from server/src/immich/controllers/tag.controller.ts
rename to server/src/controllers/tag.controller.ts
index 99715d5c72..e914e577e1 100644
--- a/server/src/immich/controllers/tag.controller.ts
+++ b/server/src/controllers/tag.controller.ts
@@ -7,7 +7,7 @@ import { AuthDto } from 'src/domain/auth/auth.dto';
 import { TagResponseDto } from 'src/domain/tag/tag-response.dto';
 import { CreateTagDto, UpdateTagDto } from 'src/domain/tag/tag.dto';
 import { TagService } from 'src/domain/tag/tag.service';
-import { Auth, Authenticated } from 'src/immich/app.guard';
+import { Auth, Authenticated } from 'src/middleware/auth.guard';
 import { UUIDParamDto } from 'src/validation';
 
 @ApiTags('Tag')
diff --git a/server/src/immich/controllers/trash.controller.ts b/server/src/controllers/trash.controller.ts
similarity index 93%
rename from server/src/immich/controllers/trash.controller.ts
rename to server/src/controllers/trash.controller.ts
index 44d68abbe4..2c0b0c946f 100644
--- a/server/src/immich/controllers/trash.controller.ts
+++ b/server/src/controllers/trash.controller.ts
@@ -3,7 +3,7 @@ import { ApiTags } from '@nestjs/swagger';
 import { BulkIdsDto } from 'src/domain/asset/response-dto/asset-ids-response.dto';
 import { AuthDto } from 'src/domain/auth/auth.dto';
 import { TrashService } from 'src/domain/trash/trash.service';
-import { Auth, Authenticated } from 'src/immich/app.guard';
+import { Auth, Authenticated } from 'src/middleware/auth.guard';
 
 @ApiTags('Trash')
 @Controller('trash')
diff --git a/server/src/immich/controllers/user.controller.ts b/server/src/controllers/user.controller.ts
similarity index 96%
rename from server/src/immich/controllers/user.controller.ts
rename to server/src/controllers/user.controller.ts
index 3f80765a97..e573584ad5 100644
--- a/server/src/immich/controllers/user.controller.ts
+++ b/server/src/controllers/user.controller.ts
@@ -24,9 +24,9 @@ import { UpdateUserDto } from 'src/domain/user/dto/update-user.dto';
 import { CreateProfileImageResponseDto } from 'src/domain/user/response-dto/create-profile-image-response.dto';
 import { UserResponseDto } from 'src/domain/user/response-dto/user-response.dto';
 import { UserService } from 'src/domain/user/user.service';
-import { AdminRoute, Auth, Authenticated, FileResponse } from 'src/immich/app.guard';
 import { sendFile } from 'src/immich/app.utils';
-import { FileUploadInterceptor, Route } from 'src/immich/interceptors/file-upload.interceptor';
+import { AdminRoute, Auth, Authenticated, FileResponse } from 'src/middleware/auth.guard';
+import { FileUploadInterceptor, Route } from 'src/middleware/file-upload.interceptor';
 import { UUIDParamDto } from 'src/validation';
 
 @ApiTags('User')
diff --git a/server/src/immich/api-v1/asset/asset.controller.ts b/server/src/immich/api-v1/asset/asset.controller.ts
index 0496c75be6..d29f61fdda 100644
--- a/server/src/immich/api-v1/asset/asset.controller.ts
+++ b/server/src/immich/api-v1/asset/asset.controller.ts
@@ -29,14 +29,9 @@ import { AssetFileUploadResponseDto } from 'src/immich/api-v1/asset/response-dto
 import { CheckExistingAssetsResponseDto } from 'src/immich/api-v1/asset/response-dto/check-existing-assets-response.dto';
 import { CuratedLocationsResponseDto } from 'src/immich/api-v1/asset/response-dto/curated-locations-response.dto';
 import { CuratedObjectsResponseDto } from 'src/immich/api-v1/asset/response-dto/curated-objects-response.dto';
-import { Auth, Authenticated, FileResponse, SharedLinkRoute } from 'src/immich/app.guard';
 import { sendFile } from 'src/immich/app.utils';
-import {
-  FileUploadInterceptor,
-  ImmichFile,
-  Route,
-  mapToUploadFile,
-} from 'src/immich/interceptors/file-upload.interceptor';
+import { Auth, Authenticated, FileResponse, SharedLinkRoute } from 'src/middleware/auth.guard';
+import { FileUploadInterceptor, ImmichFile, Route, mapToUploadFile } from 'src/middleware/file-upload.interceptor';
 import { FileNotEmptyValidator, UUIDParamDto } from 'src/validation';
 
 interface UploadFiles {
diff --git a/server/src/immich/app.module.ts b/server/src/immich/app.module.ts
index ba263622f8..66edf2341f 100644
--- a/server/src/immich/app.module.ts
+++ b/server/src/immich/app.module.ts
@@ -2,38 +2,38 @@ import { Module, OnModuleInit, ValidationPipe } from '@nestjs/common';
 import { APP_GUARD, APP_INTERCEPTOR, APP_PIPE } from '@nestjs/core';
 import { ScheduleModule } from '@nestjs/schedule';
 import { TypeOrmModule } from '@nestjs/typeorm';
+import { ActivityController } from 'src/controllers/activity.controller';
+import { AlbumController } from 'src/controllers/album.controller';
+import { APIKeyController } from 'src/controllers/api-key.controller';
+import { AppController } from 'src/controllers/app.controller';
+import { AssetController, AssetsController } from 'src/controllers/asset.controller';
+import { AuditController } from 'src/controllers/audit.controller';
+import { AuthController } from 'src/controllers/auth.controller';
+import { DownloadController } from 'src/controllers/download.controller';
+import { FaceController } from 'src/controllers/face.controller';
+import { JobController } from 'src/controllers/job.controller';
+import { LibraryController } from 'src/controllers/library.controller';
+import { OAuthController } from 'src/controllers/oauth.controller';
+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 { SharedLinkController } from 'src/controllers/shared-link.controller';
+import { SystemConfigController } from 'src/controllers/system-config.controller';
+import { TagController } from 'src/controllers/tag.controller';
+import { TrashController } from 'src/controllers/trash.controller';
+import { UserController } from 'src/controllers/user.controller';
 import { DomainModule } from 'src/domain/domain.module';
 import { AssetRepositoryV1, IAssetRepositoryV1 } from 'src/immich/api-v1/asset/asset-repository';
 import { AssetController as AssetControllerV1 } from 'src/immich/api-v1/asset/asset.controller';
 import { AssetService as AssetServiceV1 } from 'src/immich/api-v1/asset/asset.service';
-import { AppGuard } from 'src/immich/app.guard';
 import { AppService } from 'src/immich/app.service';
-import { ActivityController } from 'src/immich/controllers/activity.controller';
-import { AlbumController } from 'src/immich/controllers/album.controller';
-import { APIKeyController } from 'src/immich/controllers/api-key.controller';
-import { AppController } from 'src/immich/controllers/app.controller';
-import { AssetController, AssetsController } from 'src/immich/controllers/asset.controller';
-import { AuditController } from 'src/immich/controllers/audit.controller';
-import { AuthController } from 'src/immich/controllers/auth.controller';
-import { DownloadController } from 'src/immich/controllers/download.controller';
-import { FaceController } from 'src/immich/controllers/face.controller';
-import { JobController } from 'src/immich/controllers/job.controller';
-import { LibraryController } from 'src/immich/controllers/library.controller';
-import { OAuthController } from 'src/immich/controllers/oauth.controller';
-import { PartnerController } from 'src/immich/controllers/partner.controller';
-import { PersonController } from 'src/immich/controllers/person.controller';
-import { SearchController } from 'src/immich/controllers/search.controller';
-import { ServerInfoController } from 'src/immich/controllers/server-info.controller';
-import { SharedLinkController } from 'src/immich/controllers/shared-link.controller';
-import { SystemConfigController } from 'src/immich/controllers/system-config.controller';
-import { TagController } from 'src/immich/controllers/tag.controller';
-import { TrashController } from 'src/immich/controllers/trash.controller';
-import { UserController } from 'src/immich/controllers/user.controller';
-import { ErrorInterceptor } from 'src/immich/interceptors/error.interceptor';
-import { FileUploadInterceptor } from 'src/immich/interceptors/file-upload.interceptor';
 import { AssetEntity } from 'src/infra/entities/asset.entity';
 import { ExifEntity } from 'src/infra/entities/exif.entity';
 import { InfraModule } from 'src/infra/infra.module';
+import { AuthGuard } from 'src/middleware/auth.guard';
+import { ErrorInterceptor } from 'src/middleware/error.interceptor';
+import { FileUploadInterceptor } from 'src/middleware/file-upload.interceptor';
 
 @Module({
   imports: [
@@ -71,7 +71,7 @@ import { InfraModule } from 'src/infra/infra.module';
   providers: [
     { provide: APP_PIPE, useValue: new ValidationPipe({ transform: true, whitelist: true }) },
     { provide: APP_INTERCEPTOR, useClass: ErrorInterceptor },
-    { provide: APP_GUARD, useClass: AppGuard },
+    { provide: APP_GUARD, useClass: AuthGuard },
     { provide: IAssetRepositoryV1, useClass: AssetRepositoryV1 },
     AppService,
     AssetServiceV1,
diff --git a/server/src/immich/app.utils.ts b/server/src/immich/app.utils.ts
index 48f01d8dd5..456c9cf4e0 100644
--- a/server/src/immich/app.utils.ts
+++ b/server/src/immich/app.utils.ts
@@ -16,8 +16,8 @@ import { promisify } from 'node:util';
 import { IMMICH_ACCESS_COOKIE, IMMICH_API_KEY_HEADER, IMMICH_API_KEY_NAME } from 'src/domain/auth/auth.constant';
 import { serverVersion } from 'src/domain/domain.constant';
 import { ImmichReadStream } from 'src/domain/repositories/storage.repository';
-import { Metadata } from 'src/immich/app.guard';
 import { ImmichLogger } from 'src/infra/logger';
+import { Metadata } from 'src/middleware/auth.guard';
 import { CacheControl, ImmichFileResponse, isConnectionAborted } from 'src/utils';
 
 type SendFile = Parameters<Response['sendFile']>;
diff --git a/server/src/immich/app.guard.ts b/server/src/middleware/auth.guard.ts
similarity index 97%
rename from server/src/immich/app.guard.ts
rename to server/src/middleware/auth.guard.ts
index e465f1d401..070bf15e86 100644
--- a/server/src/immich/app.guard.ts
+++ b/server/src/middleware/auth.guard.ts
@@ -78,8 +78,8 @@ export interface AuthRequest extends Request {
 }
 
 @Injectable()
-export class AppGuard implements CanActivate {
-  private logger = new ImmichLogger(AppGuard.name);
+export class AuthGuard implements CanActivate {
+  private logger = new ImmichLogger(AuthGuard.name);
 
   constructor(
     private reflector: Reflector,
diff --git a/server/src/immich/interceptors/error.interceptor.ts b/server/src/middleware/error.interceptor.ts
similarity index 100%
rename from server/src/immich/interceptors/error.interceptor.ts
rename to server/src/middleware/error.interceptor.ts
diff --git a/server/src/immich/interceptors/file-upload.interceptor.ts b/server/src/middleware/file-upload.interceptor.ts
similarity index 98%
rename from server/src/immich/interceptors/file-upload.interceptor.ts
rename to server/src/middleware/file-upload.interceptor.ts
index 9284ade39e..a7598f99d5 100644
--- a/server/src/immich/interceptors/file-upload.interceptor.ts
+++ b/server/src/middleware/file-upload.interceptor.ts
@@ -7,8 +7,8 @@ import multer, { StorageEngine, diskStorage } from 'multer';
 import { createHash, randomUUID } from 'node:crypto';
 import { Observable } from 'rxjs';
 import { AssetService, UploadFieldName, UploadFile } from 'src/domain/asset/asset.service';
-import { AuthRequest } from 'src/immich/app.guard';
 import { ImmichLogger } from 'src/infra/logger';
+import { AuthRequest } from 'src/middleware/auth.guard';
 
 export enum Route {
   ASSET = 'asset',