ETL Pipeline (server): - POST /api/etl/sync?mode=full|incremental — fetches ERP, aggregates, writes NocoDB - nocodbClient.ts: table discovery, paginated delete/insert - etlSync.ts: orchestrates fetch → aggregate → upsert - museumMapping.ts moved from client to server - Auth via ETL_SECRET bearer token Client: - dataService.ts reverts to reading NocoDB DailySales table - Paginated fetch via fetchNocoDBTable (handles >1000 rows) - Suspicious data check: prefers cache if NocoDB returns <10 rows - Deleted erpService.ts and client-side museumMapping.ts First full sync: 391K transactions → 5,760 daily records in 108s. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import dotenv from 'dotenv';
|
|
import { fileURLToPath } from 'url';
|
|
import { dirname, resolve } from 'path';
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
dotenv.config({ path: resolve(__dirname, '..', '.env') });
|
|
|
|
export const server = {
|
|
port: parseInt(process.env.SERVER_PORT || '3002', 10),
|
|
};
|
|
|
|
export const salla = {
|
|
clientId: process.env.SALLA_CLIENT_ID || '',
|
|
clientSecret: process.env.SALLA_CLIENT_SECRET || '',
|
|
redirectUri: process.env.SALLA_REDIRECT_URI || 'http://localhost:3001/auth/callback',
|
|
accessToken: process.env.SALLA_ACCESS_TOKEN || '',
|
|
refreshToken: process.env.SALLA_REFRESH_TOKEN || '',
|
|
};
|
|
|
|
export const erp = {
|
|
apiUrl: process.env.ERP_API_URL || '',
|
|
apiCode: process.env.ERP_API_CODE || '',
|
|
username: process.env.ERP_USERNAME || '',
|
|
password: process.env.ERP_PASSWORD || '',
|
|
};
|
|
|
|
export const nocodb = {
|
|
url: process.env.NOCODB_URL || '',
|
|
token: process.env.NOCODB_TOKEN || '',
|
|
baseId: process.env.NOCODB_BASE_ID || '',
|
|
};
|
|
|
|
export const etl = {
|
|
secret: process.env.ETL_SECRET || '',
|
|
};
|