make the modules only need the app, and some minor changes

This commit is contained in:
oatmealine 2020-01-26 19:57:53 +03:00
parent 819c6623c9
commit 50e74ec760
No known key found for this signature in database
GPG Key ID: C4CB49CFAD721145
3 changed files with 14 additions and 11 deletions

View File

@ -2,8 +2,8 @@ import * as hash from './hash';
const levelsPerPage = 10; // should be kept at 10, increasing/decreasing may lead to unforseeable consequences const levelsPerPage = 10; // should be kept at 10, increasing/decreasing may lead to unforseeable consequences
module.exports = (app, db) : void => { module.exports = (app) : void => {
app.post('/aa/database/getGJLevels21.php', async (req, res) => { app.post('/' + app.get('config').addtopath + 'database/getGJLevels21.php', async (req, res) => {
let levelsString = ''; let levelsString = '';
let searchQuery: any = {}; // fuck you typescript, i have to use any or else it screams let searchQuery: any = {}; // fuck you typescript, i have to use any or else it screams
@ -50,7 +50,7 @@ module.exports = (app, db) : void => {
} }
} }
const levels = await db.collection('levels').find( const levels = await app.get('db').collection('levels').find(
{ {
$and: [ $and: [
{ {

View File

@ -18,12 +18,15 @@ dbClient.connect((err) => {
app.use(express.urlencoded({ extended: true })); app.use(express.urlencoded({ extended: true }));
app.get('/', (req, res) => { app.set('db', db);
res.send('Hello World'); app.set('config', config);
app.get('/' + config.addtopath, (req, res) => {
res.send(`${config.name} homepage - unfinished`);
}); });
require('./getGJLevels21')(app, db); require('./getGJLevels21')(app);
require('./uploadGJLevel21')(app, db); require('./uploadGJLevel21')(app);
app.get('*', (req, res) => res.status(404).send('wrong page dumbass')); app.get('*', (req, res) => res.status(404).send('wrong page dumbass'));

View File

@ -1,6 +1,6 @@
module.exports = (app, db): void => { module.exports = (app): void => {
app.post('/aa/database/uploadGJLevel21.php', async (req, res) => { app.post('/' + app.get('config').addtopath + 'database/uploadGJLevel21.php', async (req, res) => {
let levels = await db.collection('levels') let levels = await app.get('db').collection('levels')
.find({}) .find({})
.toArray(); .toArray();
@ -16,7 +16,7 @@ module.exports = (app, db): void => {
return res.status(200).send('-1'); return res.status(200).send('-1');
*/ */
db.collection('levels').insertOne({ app.get('db').collection('levels').insertOne({
'name': req.body.levelName, 'name': req.body.levelName,
'id': levelID, 'id': levelID,
'level_data': req.body.levelString, 'level_data': req.body.levelString,