Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Refactor

Edward Cui0d1e1a707669
diff --git a/server/src/api/import/importData.ts b/server/src/api/import/importData.ts
index 8cbe4245e..9a388f4aa 100644
--- a/server/src/api/import/importData.ts
+++ b/server/src/api/import/importData.ts
@@ -4,7 +4,7 @@ import fs from "fs";
import path from "path";
import { z } from "zod";
import crypto from "crypto";
-import boss from "../../lib/boss.js";
+import boss from "../../db/postgres/boss.js";
import { getUserHasAdminAccessToSite } from "../../lib/auth-utils.js";
import { CSV_PARSE_QUEUE } from "../../types/import.js";
import { ImportRateLimiter } from "../../lib/rateLimiter.js";
diff --git a/server/src/lib/boss.ts b/server/src/db/postgres/boss.ts
similarity index 100%
rename from server/src/lib/boss.ts
rename to server/src/db/postgres/boss.ts
diff --git a/server/src/index.ts b/server/src/index.ts
index 557d12224..e12a2c2fe 100644
--- a/server/src/index.ts
+++ b/server/src/index.ts
@@ -75,7 +75,7 @@ import { trackEvent } from "./services/tracker/trackEvent.js";
import { telemetryService } from "./services/telemetryService.js";
import { extractSiteId, isSitePublic } from "./utils.js";
import { importData } from "./api/import/importData.js";
-import boss from "./lib/boss.js";
+import boss from "./db/postgres/boss.js";
import { registerCsvParseWorker } from "./workers/csvParseWorker.js";
import { registerDataInsertWorker } from "./workers/dataInsertWorker.js";
import { listSiteImports } from "./api/import/listSiteImports.js";
diff --git a/server/src/lib/dataValidation.ts b/server/src/lib/dataValidation.ts
index 50f9a1eff..acfc99b42 100644
--- a/server/src/lib/dataValidation.ts
+++ b/server/src/lib/dataValidation.ts
@@ -1,7 +1,7 @@
import { z } from "zod";
import { SecurityValidator } from "./security.js";
-export class DataValidator {
+export class ImportDataValidator {
private static readonly MAX_STRING_LENGTH = 1000;
private static readonly MAX_URL_LENGTH = 2000;
private static readonly VALID_LANGUAGES = new Set([
@@ -43,7 +43,7 @@ export class DataValidator {
}),
});
- static validateUmamiEvent(event: any): z.infer<typeof DataValidator.umamiEventSchema> {
+ static validateUmamiEvent(event: any): z.infer<typeof ImportDataValidator.umamiEventSchema> {
return this.umamiEventSchema.parse(event);
}
diff --git a/server/src/lib/errorHandling.ts b/server/src/lib/errorHandling.ts
deleted file mode 100644
index 34baeb858..000000000
--- a/server/src/lib/errorHandling.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-export class ImportValidator {
- // TODO: Implement
- static validateUmamiDataIntegrity(row: any, rowIndex: number): void {
- // Check required fields/columns
- // Validate timestamp format
- // Validate timestamp is not in the future
- }
-}
diff --git a/server/src/workers/csvParseWorker.ts b/server/src/workers/csvParseWorker.ts
index 67c8e6326..a9ca73aad 100644
--- a/server/src/workers/csvParseWorker.ts
+++ b/server/src/workers/csvParseWorker.ts
@@ -1,6 +1,6 @@
import fs from "fs";
import { parseStream } from "@fast-csv/parse";
-import boss from "../lib/boss.js";
+import boss from "../db/postgres/boss.js";
import { CSV_PARSE_QUEUE, CsvParseJob, DATA_INSERT_QUEUE } from "../types/import.js";
import { Job } from "pg-boss";
import { UmamiEvent, umamiHeaders } from "./mappings/umami.js";
diff --git a/server/src/workers/dataInsertWorker.ts b/server/src/workers/dataInsertWorker.ts
index 834db1f7a..a63861e3d 100644
--- a/server/src/workers/dataInsertWorker.ts
+++ b/server/src/workers/dataInsertWorker.ts
@@ -1,4 +1,4 @@
-import boss from "../lib/boss.js";
+import boss from "../db/postgres/boss.js";
import { UmamiEvent, UmamiImportMapper } from "./mappings/umami.js";
import { DataInsertJob, DATA_INSERT_QUEUE } from "../types/import.js";
import { clickhouse } from "../db/clickhouse/clickhouse.js";