modified: js/server.js
This commit is contained in:
12
js/server.js
12
js/server.js
@ -3,10 +3,11 @@ const fs = require('fs');
|
|||||||
const cors = require('cors');
|
const cors = require('cors');
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|
||||||
const LEADERBOARD_FILE = './leaderboard.json';
|
const LEADERBOARD_FILE = '../data/leaderboard.json';
|
||||||
const INACTIVE_DAYS = 30; // Completely remove from JSON after 5 days
|
const INACTIVE_DAYS = 30; // Completely remove from JSON after 5 days
|
||||||
const LEADERBOARD_VISIBLE_DAYS = 5; // Only show on leaderboard if active within 5 days
|
const LEADERBOARD_VISIBLE_DAYS = 5; // Only show on leaderboard if active within 5 days
|
||||||
|
|
||||||
@ -159,6 +160,10 @@ app.post('/api/checkpoint', (req, res) => {
|
|||||||
|
|
||||||
saveLeaderboard(leaderboard);
|
saveLeaderboard(leaderboard);
|
||||||
|
|
||||||
|
const timestamp = new Date().toLocaleString();
|
||||||
|
const SOLAR_MASS_KG = 1.989e30;
|
||||||
|
console.log(`${timestamp} Checkpoint: ${playerId.slice(-5)} | Mass: ${(gameState.blackHoleTotalMass / SOLAR_MASS_KG).toFixed(3)} M☉ | Level: ${player.level}`);
|
||||||
|
|
||||||
res.json({ success: true });
|
res.json({ success: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -299,11 +304,6 @@ setInterval(cleanupBotAccounts, 24 * 60 * 60 * 1000);
|
|||||||
// Run cleanup on startup too
|
// Run cleanup on startup too
|
||||||
cleanupBotAccounts();
|
cleanupBotAccounts();
|
||||||
|
|
||||||
// Block direct access to leaderboard.json
|
|
||||||
app.get('/leaderboard.json', (req, res) => {
|
|
||||||
res.status(403).json({ error: 'Access denied' });
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create a transfer code for session migration
|
// Create a transfer code for session migration
|
||||||
app.post('/api/transfer/create', (req, res) => {
|
app.post('/api/transfer/create', (req, res) => {
|
||||||
const { playerId, secretToken } = req.body;
|
const { playerId, secretToken } = req.body;
|
||||||
|
|||||||
Reference in New Issue
Block a user