Skip to content

Commit a80e975

Browse files
author
Elkin
committed
feat: backend en tiempo real con Socket.IO y soporte para Render
1 parent 5224107 commit a80e975

13 files changed

Lines changed: 28627 additions & 9 deletions

File tree

‎package-lock.json‎

Lines changed: 109 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"lucide-react": "^1.70.0",
1818
"react": "^19.3.1",
1919
"react-dom": "^19.3.1",
20+
"socket.io-client": "^4.8.4",
2021
"tailwindcss": "^4.3.5",
2122
"xlsx": "^0.18.5"
2223
},

‎render.yaml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
services:
2+
- type: web
3+
name: juegos-asocomunales-api
4+
env: node
5+
plan: free
6+
buildCommand: cd server && npm install
7+
startCommand: cd server && npm start
8+
envVars:
9+
- key: NODE_ENV
10+
value: production
11+
- key: COORDINATOR_PIN
12+
value: "2026"

‎scripts/exportBaselineToJson.js‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
4+
// Read initialData.ts
5+
const initialDataPath = path.resolve('src/data/initialData.ts');
6+
const content = fs.readFileSync(initialDataPath, 'utf8');
7+
8+
// Helper to extract exported const JSON arrays/objects
9+
function extractConst(name) {
10+
const marker = `export const ${name}`;
11+
const startIdx = content.indexOf(marker);
12+
if (startIdx === -1) return null;
13+
const eqIdx = content.indexOf('=', startIdx);
14+
const openBracket = content.indexOf('[', eqIdx);
15+
const openBrace = content.indexOf('{', eqIdx);
16+
17+
let isArray = false;
18+
let startCharIdx = -1;
19+
if (openBracket !== -1 && (openBrace === -1 || openBracket < openBrace)) {
20+
isArray = true;
21+
startCharIdx = openBracket;
22+
} else if (openBrace !== -1) {
23+
isArray = false;
24+
startCharIdx = openBrace;
25+
}
26+
27+
// Find matching closing bracket/brace
28+
let depth = 0;
29+
let endCharIdx = -1;
30+
const openChar = isArray ? '[' : '{';
31+
const closeChar = isArray ? ']' : '}';
32+
33+
for (let i = startCharIdx; i < content.length; i++) {
34+
if (content[i] === openChar) depth++;
35+
else if (content[i] === closeChar) {
36+
depth--;
37+
if (depth === 0) {
38+
endCharIdx = i;
39+
break;
40+
}
41+
}
42+
}
43+
44+
const rawStr = content.slice(startCharIdx, endCharIdx + 1);
45+
return JSON.parse(rawStr);
46+
}
47+
48+
const jacs = extractConst('SABANETA_JACS');
49+
const athletes = extractConst('INITIAL_ATHLETES');
50+
const registrations = extractConst('INITIAL_REGISTRATIONS');
51+
const matches = [];
52+
const medals = extractConst('INITIAL_MEDALS');
53+
54+
const baseline = {
55+
jacs,
56+
athletes,
57+
registrations,
58+
matches,
59+
medals
60+
};
61+
62+
const outDir = path.resolve('server/data');
63+
if (!fs.existsSync(outDir)) {
64+
fs.mkdirSync(outDir, { recursive: true });
65+
}
66+
67+
fs.writeFileSync(path.join(outDir, 'baseline.json'), JSON.stringify(baseline, null, 2), 'utf8');
68+
console.log(`✅ Baseline exported to server/data/baseline.json with ${athletes.length} athletes, ${registrations.length} registrations, ${jacs.length} JACs.`);

0 commit comments

Comments
 (0)