-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataService.js
More file actions
44 lines (36 loc) · 1.09 KB
/
Copy pathdataService.js
File metadata and controls
44 lines (36 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* Configuración centralizada del servicio de datos
* Cambia entre mockService y firestore modificando una sola línea
*/
// ========== CONFIGURACIÓN ==========
// Cambia 'mockService' por 'firestore' para usar Firebase
const USE_SERVICE = 'firestore';
// ===================================
// Imports condicionales
import * as mockService from './mockService.js';
import * as firestore from './firestore.js';
// Seleccionar el servicio activo
const services = {
mockService,
firestore
};
const activeService = services[USE_SERVICE];
if (!activeService) {
throw new Error(`Servicio "${USE_SERVICE}" no válido. Usa 'mockService' o 'firestore'`);
}
// Re-exportar todas las funciones del servicio activo
export const {
default: getData,
getItemData,
getCategoryData,
getCategories,
searchByTitle,
createBuyOrder,
getOrders
} = activeService;
// Exportación por defecto
export default getData;
// Log para verificar qué servicio está activo (solo en desarrollo)
if (import.meta.env.DEV) {
console.log(`📦 Servicio de datos activo: ${USE_SERVICE}`);
}