Reaperxxxx commited on
Commit
f01243a
Β·
verified Β·
1 Parent(s): 6903460

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +24 -3
index.js CHANGED
@@ -67,6 +67,22 @@ app.get('/tools', (req, res) => {
67
  res.json(checkTools());
68
  });
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  // GET /init β€” load bundled APK from disk, no upload needed
71
  const BUNDLED_APK = path.join(__dirname, 'super-city-2.010.64-mod-t-5play.apk');
72
 
@@ -76,8 +92,13 @@ app.get('/init', (req, res) => {
76
  }
77
  try {
78
  const zip = new AdmZip(BUNDLED_APK);
79
- const entry = zip.getEntry('assets/characters.txt');
80
- if (!entry) return res.status(400).json({ error: 'assets/characters.txt not found in APK' });
 
 
 
 
 
81
 
82
  const content = entry.getData().toString('utf8');
83
  const token = Date.now() + '_' + Math.random().toString(36).slice(2);
@@ -247,7 +268,7 @@ app.get('/', (req, res) => {
247
  });
248
 
249
  // ── START ─────────────────────────────────────────────────────────────────────
250
- app.listen(7860, () => {
251
  console.log(`\n🦸 Super City Editor backend running at http://localhost:${PORT}`);
252
  console.log('Open that URL in your browser to use the editor.\n');
253
  try { ensureKeystore(); } catch (e) { console.warn('Keystore not ready yet:', e.message); }
 
67
  res.json(checkTools());
68
  });
69
 
70
+ // GET /debug β€” APK diagnostics
71
+ app.get('/debug', (req, res) => {
72
+ const exists = fs.existsSync(BUNDLED_APK);
73
+ if (!exists) return res.json({ exists: false, path: BUNDLED_APK });
74
+
75
+ const stat = fs.statSync(BUNDLED_APK);
76
+ try {
77
+ const zip = new AdmZip(BUNDLED_APK);
78
+ const entries = zip.getEntries().map(e => e.entryName);
79
+ const hasChars = entries.some(e => e.replace(/\\/g, '/').toLowerCase() === 'assets/characters.txt');
80
+ res.json({ exists: true, path: BUNDLED_APK, sizeBytes: stat.size, entryCount: entries.length, hasCharactersTxt: hasChars, entries });
81
+ } catch (err) {
82
+ res.json({ exists: true, path: BUNDLED_APK, sizeBytes: stat.size, zipError: err.message });
83
+ }
84
+ });
85
+
86
  // GET /init β€” load bundled APK from disk, no upload needed
87
  const BUNDLED_APK = path.join(__dirname, 'super-city-2.010.64-mod-t-5play.apk');
88
 
 
92
  }
93
  try {
94
  const zip = new AdmZip(BUNDLED_APK);
95
+ const entry = zip.getEntries().find(e =>
96
+ e.entryName.replace(/\\/g, '/').toLowerCase() === 'assets/characters.txt'
97
+ );
98
+ if (!entry) {
99
+ const names = zip.getEntries().map(e => e.entryName).join(', ');
100
+ return res.status(400).json({ error: `assets/characters.txt not found. Entries: ${names}` });
101
+ }
102
 
103
  const content = entry.getData().toString('utf8');
104
  const token = Date.now() + '_' + Math.random().toString(36).slice(2);
 
268
  });
269
 
270
  // ── START ─────────────────────────────────────────────────────────────────────
271
+ app.listen(PORT, () => {
272
  console.log(`\n🦸 Super City Editor backend running at http://localhost:${PORT}`);
273
  console.log('Open that URL in your browser to use the editor.\n');
274
  try { ensureKeystore(); } catch (e) { console.warn('Keystore not ready yet:', e.message); }