Version 1.0 squash

This commit is contained in:
Kenan Alić
2025-10-21 18:45:02 +02:00
parent 8c1f041fa0
commit a481044c43
30 changed files with 2534 additions and 15 deletions

51
web/src/lib/pocketbase.ts Normal file
View File

@@ -0,0 +1,51 @@
/**
* PocketBase Client Configuration
*
* Singleton PocketBase client instance with automatic environment detection.
* Connects to local instance in development, production URL in production.
*/
import PocketBase from "pocketbase";
/**
* PocketBase URL configuration based on environment
* Development: Local PocketBase instance (http://127.0.0.1:8090)
* Production: Production PocketBase instance
*
* @returns PocketBase API base URL
*/
const getPocketBaseUrl = (): string => {
const isDev = import.meta.env.MODE === "development";
if (isDev) {
return "http://localhost:8090";
}
/* Production URL - configure via build process or use relative URL */
return import.meta.env.VITE_POCKETBASE_URL || "http://localhost:8090";
};
/**
* Singleton PocketBase client instance
* Import this instance throughout the application for all PocketBase operations
*/
export const pb = new PocketBase(getPocketBaseUrl());
/**
* Disable auto-cancellation to prevent request interruptions
* By default, PocketBase cancels pending requests when new ones are made,
* which can cause issues with concurrent requests and real-time subscriptions
*/
pb.autoCancellation(false);
/**
* PocketBase collection names
* Centralized collection name constants to avoid typos and enable refactoring
*/
export const Collections = {
About: "about",
Companies: "companies",
Notices: "notices",
FloorPlans: "floor_plans",
Rooms: "rooms",
} as const;