import * as hash from './hash'; module.exports = (app, db) : void => { app.post('/aa/database/getGJLevels21.php', async (req, res) => { let levelsString = ''; const levels = await db.collection('levels').find({}) .toArray(); // TODO: searching let results = levels .map(l => `1:${l.id}:2:${l.name}:5:0:6:16:8:10:9:${l.diff}:10:${l.downloads}:12:1:13:21:14:${l.likes}:17:0:43:0:25:0:18:${l.stars}:19:0:42:0:45:10:3:${l.description}:15:1:30:0:31:0:37:0:38:0:39:0:46:1:47:2:40:0:35:0` ) .join('|'); let users = new Array(levels.length) // placeholder .fill('16:mat:0') .join('|'); let songs = ''; // placeholder levelsString = [results, users, songs, levels.length].join('#') + ':0:10#' + hash.hashLevels(levels); res.status(200).send(levelsString); }); };