studyup 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/2048-package/README.md +29 -0
- package/2048-package/assets/Screenshots-2048-Game.jpg +0 -0
- package/2048-package/css/style.css +69 -0
- package/2048-package/index.html +23 -0
- package/2048-package/src/script.js +270 -0
- package/classicube-package/README.md +5 -0
- package/classicube-package/css/style.css +7 -0
- package/classicube-package/index.html +72 -0
- package/classicube-package/js/ClassiCube.js +63288 -0
- package/classicube-package/js/jquery.js +2 -0
- package/classicube-package/static/default.zip +0 -0
- package/index.html +852 -517
- package/package.json +1 -1
- package/server.js +50 -0
package/package.json
CHANGED
package/server.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
const app = express();
|
|
6
|
+
const PORT = process.env.PORT || 3000;
|
|
7
|
+
const DATA_FILE = path.join(__dirname, 'data.json');
|
|
8
|
+
|
|
9
|
+
app.use(express.json());
|
|
10
|
+
// Serve static files from the same root folder where server.js lives
|
|
11
|
+
app.use(express.static(__dirname));
|
|
12
|
+
|
|
13
|
+
// Helper to read data
|
|
14
|
+
function getData() {
|
|
15
|
+
if (!fs.existsSync(DATA_FILE)) {
|
|
16
|
+
const defaultData = {
|
|
17
|
+
globalBlock: false,
|
|
18
|
+
codes: {
|
|
19
|
+
"123456": { games: ["Sandboxels", "HexGL", "ClassiCube", "2048"] }
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
fs.writeFileSync(DATA_FILE, JSON.stringify(defaultData, null, 2));
|
|
23
|
+
return defaultData;
|
|
24
|
+
}
|
|
25
|
+
return JSON.parse(fs.readFileSync(DATA_FILE, 'utf8'));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Helper to write data
|
|
29
|
+
function saveData(data) {
|
|
30
|
+
fs.writeFileSync(DATA_FILE, JSON.stringify(data, null, 2));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// API: Get current config
|
|
34
|
+
app.get('/api/config', (req, res) => {
|
|
35
|
+
res.json(getData());
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// API: Save/Update config (Admin actions)
|
|
39
|
+
app.post('/api/config', (req, res) => {
|
|
40
|
+
try {
|
|
41
|
+
saveData(req.body);
|
|
42
|
+
res.json({ success: true });
|
|
43
|
+
} catch (err) {
|
|
44
|
+
res.status(500).json({ success: false, error: err.message });
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
app.listen(PORT, () => {
|
|
49
|
+
console.log(`StudyUp server running on port ${PORT}`);
|
|
50
|
+
});
|