mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 21:34:24 +00:00
general event settings done
This commit is contained in:
@@ -9,13 +9,14 @@
|
||||
|
||||
const posth = require( './api/postHandler.js' );
|
||||
const geth = require( './api/getHandler.js' );
|
||||
const postHandler = new posth();
|
||||
const path = require( 'path' );
|
||||
const bodyParser = require( 'body-parser' );
|
||||
const mlt = require( 'multer' );
|
||||
const multer = mlt();
|
||||
const fs = require( 'fs' );
|
||||
const getHandler = new geth( JSON.parse( fs.readFileSync( path.join( __dirname + '/../config/settings.config.json' ) ) ) );
|
||||
const settings = JSON.parse( fs.readFileSync( path.join( __dirname + '/../config/settings.config.json' ) ) );
|
||||
const getHandler = new geth( settings );
|
||||
const postHandler = new posth( settings );
|
||||
|
||||
|
||||
// settings is missing in arguments which shouldn't pose any problem
|
||||
@@ -39,6 +40,7 @@ module.exports = ( app ) => {
|
||||
postHandler.handleCall( req.params.call, req.body, req.query.lang ).then( data => {
|
||||
res.send( data );
|
||||
} ).catch( error => {
|
||||
console.error( error );
|
||||
res.status( error.code ).send( error.error );
|
||||
} );
|
||||
} else {
|
||||
|
||||
@@ -8,10 +8,12 @@
|
||||
*/
|
||||
|
||||
const db = require( '../../backend/db/db.js' );
|
||||
const fs = require( 'fs' );
|
||||
const path = require( 'path' );
|
||||
|
||||
class POSTHandler {
|
||||
constructor () {
|
||||
|
||||
constructor ( settings ) {
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
handleCall ( call, data, lang ) {
|
||||
@@ -113,8 +115,12 @@ class POSTHandler {
|
||||
} else if ( call === 'deleteAdminAccount' ) {
|
||||
// TODO: Finish
|
||||
} else if ( call === 'updateSettings' ) {
|
||||
// TODO: Finish
|
||||
this.settings[ 'twoFA' ] = data.twoFA;
|
||||
this.settings[ 'currency' ] = data.currency;
|
||||
this.settings[ 'payments' ] = data.payments;
|
||||
fs.writeFileSync( path.join( __dirname + '/../../config/settings.config.json' ), JSON.stringify( this.settings ) );
|
||||
// TODO: Parse all events and update currency
|
||||
resolve( 'ok' );
|
||||
} else {
|
||||
reject( { 'code': 404, 'error': 'Route not found' } );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user