make the modules only need the app, and some minor changes
This commit is contained in:
parent
819c6623c9
commit
50e74ec760
|
@ -2,8 +2,8 @@ import * as hash from './hash';
|
|||
|
||||
const levelsPerPage = 10; // should be kept at 10, increasing/decreasing may lead to unforseeable consequences
|
||||
|
||||
module.exports = (app, db) : void => {
|
||||
app.post('/aa/database/getGJLevels21.php', async (req, res) => {
|
||||
module.exports = (app) : void => {
|
||||
app.post('/' + app.get('config').addtopath + 'database/getGJLevels21.php', async (req, res) => {
|
||||
let levelsString = '';
|
||||
|
||||
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: [
|
||||
{
|
||||
|
|
11
src/index.ts
11
src/index.ts
|
@ -18,12 +18,15 @@ dbClient.connect((err) => {
|
|||
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
res.send('Hello World');
|
||||
app.set('db', db);
|
||||
app.set('config', config);
|
||||
|
||||
app.get('/' + config.addtopath, (req, res) => {
|
||||
res.send(`${config.name} homepage - unfinished`);
|
||||
});
|
||||
|
||||
require('./getGJLevels21')(app, db);
|
||||
require('./uploadGJLevel21')(app, db);
|
||||
require('./getGJLevels21')(app);
|
||||
require('./uploadGJLevel21')(app);
|
||||
|
||||
app.get('*', (req, res) => res.status(404).send('wrong page dumbass'));
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module.exports = (app, db): void => {
|
||||
app.post('/aa/database/uploadGJLevel21.php', async (req, res) => {
|
||||
let levels = await db.collection('levels')
|
||||
module.exports = (app): void => {
|
||||
app.post('/' + app.get('config').addtopath + 'database/uploadGJLevel21.php', async (req, res) => {
|
||||
let levels = await app.get('db').collection('levels')
|
||||
.find({})
|
||||
.toArray();
|
||||
|
||||
|
@ -16,7 +16,7 @@ module.exports = (app, db): void => {
|
|||
return res.status(200).send('-1');
|
||||
*/
|
||||
|
||||
db.collection('levels').insertOne({
|
||||
app.get('db').collection('levels').insertOne({
|
||||
'name': req.body.levelName,
|
||||
'id': levelID,
|
||||
'level_data': req.body.levelString,
|
||||
|
|
Loading…
Reference in New Issue