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>
46 lines
946 B
Bash
Executable File
46 lines
946 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Temporary dev script for ERP migration — starts NocoDB + Express server + Vite
|
|
|
|
set -e
|
|
|
|
cleanup() {
|
|
echo ""
|
|
echo "Shutting down..."
|
|
kill $SERVER_PID $CLIENT_PID 2>/dev/null
|
|
docker stop nocodb 2>/dev/null
|
|
echo "Done."
|
|
}
|
|
|
|
trap cleanup EXIT INT TERM
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
# Start NocoDB
|
|
if docker ps --format '{{.Names}}' | grep -q '^nocodb$'; then
|
|
echo "NocoDB already running on port 8090"
|
|
else
|
|
echo "Starting NocoDB..."
|
|
docker start nocodb 2>/dev/null || docker run -d \
|
|
--name nocodb -p 8090:8080 nocodb/nocodb:latest
|
|
fi
|
|
|
|
echo "Waiting for NocoDB..."
|
|
for i in $(seq 1 30); do
|
|
curl -s http://localhost:8090/api/v1/health >/dev/null 2>&1 && echo "NocoDB ready" && break
|
|
sleep 1
|
|
done
|
|
|
|
# Start Express server (port 3002)
|
|
echo "Starting Express server..."
|
|
(cd server && npm run dev) &
|
|
SERVER_PID=$!
|
|
|
|
sleep 2
|
|
|
|
# Start Vite (port 3000)
|
|
echo "Starting Vite..."
|
|
npx vite &
|
|
CLIENT_PID=$!
|
|
|
|
wait $CLIENT_PID
|