Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

refactor(server): move the KML importer and place-image helpers into places/ (#1832)

Maurice4e6b45016a9c
diff --git a/server/src/nest/collections/collections.controller.ts b/server/src/nest/collections/collections.controller.ts
index 94c686778..5d8733bda 100644
--- a/server/src/nest/collections/collections.controller.ts
+++ b/server/src/nest/collections/collections.controller.ts
@@ -31,7 +31,7 @@ import { ADDON_IDS } from '../../addons';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
import { CurrentUser } from '../auth/current-user.decorator';
import { PLACE_IMAGE_UPLOAD } from '../common/place-image-upload';
-import { placeImageUrl } from '../../services/placeImage';
+import { placeImageUrl } from '../places/place-image';
import {
CollectionCreateDto,
CollectionUpdateDto,
diff --git a/server/src/nest/collections/collections.service.ts b/server/src/nest/collections/collections.service.ts
index bd6cf8bda..2ca0e74e7 100644
--- a/server/src/nest/collections/collections.service.ts
+++ b/server/src/nest/collections/collections.service.ts
@@ -4,7 +4,7 @@ import { Injectable } from '@nestjs/common';
import { DatabaseService } from '../database/database.service';
import { PermissionsService } from '../permissions/permissions.service';
import { RealtimeService } from '../realtime/realtime.service';
-import { reclaimPlaceImage } from '../../services/placeImage';
+import { reclaimPlaceImage } from '../places/place-image';
import type {
Collection,
CollectionDetailResponse,
diff --git a/server/src/nest/common/place-image-upload.ts b/server/src/nest/common/place-image-upload.ts
index 14c038208..61aacb21f 100644
--- a/server/src/nest/common/place-image-upload.ts
+++ b/server/src/nest/common/place-image-upload.ts
@@ -3,7 +3,7 @@ import path from 'path';
import { diskStorage } from 'multer';
import { v4 as uuidv4 } from 'uuid';
import type { Request } from 'express';
-import { PLACE_IMAGES_DIR } from '../../services/placeImage';
+import { PLACE_IMAGES_DIR } from '../places/place-image';
const MAX_PLACE_IMAGE_SIZE = 20 * 1024 * 1024; // 20 MB — same cap as covers.
diff --git a/server/src/services/kmlImport.ts b/server/src/nest/places/kml-import.helpers.ts
similarity index 100%
rename from server/src/services/kmlImport.ts
rename to server/src/nest/places/kml-import.helpers.ts
diff --git a/server/src/services/placeImage.ts b/server/src/nest/places/place-image.ts
similarity index 92%
rename from server/src/services/placeImage.ts
rename to server/src/nest/places/place-image.ts
index b76df1b86..b35d5fa29 100644
--- a/server/src/services/placeImage.ts
+++ b/server/src/nest/places/place-image.ts
@@ -1,11 +1,11 @@
import fs from 'fs';
import path from 'path';
-import { db } from '../db/database';
+import { db } from '../../db/database';
// Custom place images (the user-uploaded thumbnails from #1136) live in their own
// uploads subdir, served statically like covers. Storing the full /uploads/places/…
// path in image_url lets every existing thumbnail renderer show it unchanged.
-export const PLACE_IMAGES_DIR = path.resolve(__dirname, '../../uploads/places');
+export const PLACE_IMAGES_DIR = path.resolve(__dirname, '../../../uploads/places');
const URL_PREFIX = '/uploads/places/';
export function placeImageUrl(filename: string): string {
diff --git a/server/src/nest/places/places.controller.ts b/server/src/nest/places/places.controller.ts
index ca5960f7e..3acb5727c 100644
--- a/server/src/nest/places/places.controller.ts
+++ b/server/src/nest/places/places.controller.ts
@@ -25,7 +25,7 @@ import { isUpdateConflict } from '../common/conflictResult';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
import { CurrentUser } from '../auth/current-user.decorator';
import { PLACE_IMAGE_UPLOAD } from '../common/place-image-upload';
-import { placeImageUrl } from '../../services/placeImage';
+import { placeImageUrl } from './place-image';
import {
PlaceBulkDeleteDto,
PlaceBulkUpdateDto,
diff --git a/server/src/nest/places/places.helpers.ts b/server/src/nest/places/places.helpers.ts
index 3f700cee9..5eae0c2c6 100644
--- a/server/src/nest/places/places.helpers.ts
+++ b/server/src/nest/places/places.helpers.ts
@@ -2,7 +2,7 @@ import { XMLParser } from 'fast-xml-parser';
import unzipper from 'unzipper';
import type { Place } from '../../types';
import type { PlaceWithTags } from '../database/database.service';
-import type { KmlImportSummary } from '../../services/kmlImport';
+import type { KmlImportSummary } from './kml-import.helpers';
import * as placePhotoCache from '../../services/placePhotoCache';
/**
diff --git a/server/src/nest/places/places.service.ts b/server/src/nest/places/places.service.ts
index c0c7feaec..c209090a7 100644
--- a/server/src/nest/places/places.service.ts
+++ b/server/src/nest/places/places.service.ts
@@ -18,10 +18,10 @@ import {
extractKmlPlacemarkNodes,
parsePlacemarkNode,
resolveCategoryIdForFolder,
-} from '../../services/kmlImport';
+} from './kml-import.helpers';
import { UnsplashService } from '../unsplash/unsplash.service';
import { type UpdateConflict, isUpdateConflict } from '../common/conflictResult';
-import { reclaimPlaceImage } from '../../services/placeImage';
+import { reclaimPlaceImage } from './place-image';
import { onPlaceCreated, onPlaceUpdated, onPlaceDeleted } from '../../services/journeyService';
import {
COORD_DEDUP_TOLERANCE,
diff --git a/server/tests/unit/nest/collections.service.test.ts b/server/tests/unit/nest/collections.service.test.ts
index 3e5de7fbe..76d4ab9ab 100644
--- a/server/tests/unit/nest/collections.service.test.ts
+++ b/server/tests/unit/nest/collections.service.test.ts
@@ -54,7 +54,7 @@ import { PermissionsService } from '../../../src/nest/permissions/permissions.se
import { RealtimeService } from '../../../src/nest/realtime/realtime.service';
import { CollectionsService } from '../../../src/nest/collections/collections.service';
import { removeIfUnreferenced } from '../../../src/services/placePhotoCache';
-import { PLACE_IMAGES_DIR } from '../../../src/services/placeImage';
+import { PLACE_IMAGES_DIR } from '../../../src/nest/places/place-image';
const svc = new CollectionsService(new DatabaseService(testDb), new PermissionsService(new DatabaseService(testDb)), new RealtimeService());
diff --git a/server/tests/unit/nest/places.service.test.ts b/server/tests/unit/nest/places.service.test.ts
index be2bcb9ab..794ff5099 100644
--- a/server/tests/unit/nest/places.service.test.ts
+++ b/server/tests/unit/nest/places.service.test.ts
@@ -70,7 +70,7 @@ import { RealtimeService } from '../../../src/nest/realtime/realtime.service';
import { PlacesService } from '../../../src/nest/places/places.service';
import { MapsService } from '../../../src/nest/maps/maps.service';
import { QueryHelpersService } from '../../../src/nest/query-helpers/query-helpers.service';
-import { PLACE_IMAGES_DIR } from '../../../src/services/placeImage';
+import { PLACE_IMAGES_DIR } from '../../../src/nest/places/place-image';
const GPX_FIXTURE = path.join(__dirname, '../../fixtures/test.gpx');
const KML_FIXTURE = path.join(__dirname, '../../fixtures/test.kml');
diff --git a/server/tests/unit/services/kmlImportUtils.test.ts b/server/tests/unit/nest/places/kml-import.helpers.test.ts
similarity index 98%
rename from server/tests/unit/services/kmlImportUtils.test.ts
rename to server/tests/unit/nest/places/kml-import.helpers.test.ts
index 47cd40e27..d2d42f8e1 100644
--- a/server/tests/unit/services/kmlImportUtils.test.ts
+++ b/server/tests/unit/nest/places/kml-import.helpers.test.ts
@@ -7,7 +7,7 @@ import {
parsePlacemarkNode,
resolveCategoryIdForFolder,
sanitizeKmlDescription,
-} from '../../../src/services/kmlImport';
+} from '../../../../src/nest/places/kml-import.helpers';
describe('kmlImportUtils', () => {
it('sanitizes HTML descriptions with br to newline', () => {