Reaperxxxx commited on
Commit
992ca58
Β·
verified Β·
1 Parent(s): bc70371

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +26 -2
index.js CHANGED
@@ -8,7 +8,7 @@ const { execSync, spawnSync } = require('child_process');
8
  const axios = require('axios');
9
 
10
  const app = express();
11
- const PORT = 7860;
12
 
13
  app.use(express.json({ limit: '200mb' }));
14
  app.use(express.static(path.join(__dirname, 'public')));
@@ -67,6 +67,30 @@ app.get('/tools', (req, res) => {
67
  res.json(checkTools());
68
  });
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  // POST /upload β€” receive APK, extract characters.txt, return it as text
71
  app.post('/upload', upload.single('apk'), (req, res) => {
72
  try {
@@ -223,7 +247,7 @@ app.get('/', (req, res) => {
223
  });
224
 
225
  // ── START ─────────────────────────────────────────────────────────────────────
226
- app.listen(PORT, () => {
227
  console.log(`\n🦸 Super City Editor backend running at http://localhost:${PORT}`);
228
  console.log('Open that URL in your browser to use the editor.\n');
229
  try { ensureKeystore(); } catch (e) { console.warn('Keystore not ready yet:', e.message); }
 
8
  const axios = require('axios');
9
 
10
  const app = express();
11
+ const PORT = 3000;
12
 
13
  app.use(express.json({ limit: '200mb' }));
14
  app.use(express.static(path.join(__dirname, 'public')));
 
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
+
73
+ app.get('/init', (req, res) => {
74
+ if (!fs.existsSync(BUNDLED_APK)) {
75
+ return res.status(404).json({ error: 'Bundled APK not found on server' });
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);
84
+ const sessionDir = path.join(os.tmpdir(), token);
85
+ fs.mkdirSync(sessionDir);
86
+ fs.copyFileSync(BUNDLED_APK, path.join(sessionDir, 'original.apk'));
87
+ fs.writeFileSync(path.join(sessionDir, 'original_name.txt'), path.basename(BUNDLED_APK));
88
+ res.json({ token, characters: content });
89
+ } catch (err) {
90
+ res.status(500).json({ error: err.message });
91
+ }
92
+ });
93
+
94
  // POST /upload β€” receive APK, extract characters.txt, return it as text
95
  app.post('/upload', upload.single('apk'), (req, res) => {
96
  try {
 
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); }