1.1.18 - imagine useful commit messages

This commit is contained in:
exttex
2021-04-01 19:47:42 +02:00
parent 984a5d9296
commit 85f293893a
23 changed files with 15937 additions and 284 deletions

View File

@ -1,4 +1,5 @@
const express = require('express');
const cors = require('cors');
const path = require('path');
const packageJson = require('../package.json');
const fs = require('fs');
@ -11,7 +12,6 @@ const {Track, Album, Artist, Playlist, DeezerProfile, SearchResults, DeezerLibra
const {DownloadManager} = require('./downloads');
const {Integrations} = require('./integrations');
const {Importer} = require('./importer');
const { url } = require('inspector');
let settings;
let deezer;
@ -24,6 +24,7 @@ let sockets = [];
const app = express();
app.use(express.json({limit: '50mb'}));
app.use(express.static(path.join(__dirname, '../client', 'dist')));
app.use(cors({origin: 'http://localhost:8080'}));
//Server
const server = require('http').createServer(app);
const io = require('socket.io').listen(server, {
@ -632,6 +633,15 @@ app.get('/updates', async (req, res) => {
}
});
//Background image
app.get('/background', async (req, res) => {
//Missing
if (!settings.backgroundImage && !fs.existsSync(settings.backgroundImage)) {
return res.status(404).end();
}
res.sendFile(path.resolve(settings.backgroundImage));
});
//Redirect to index on unknown path
app.all('*', (req, res) => {
res.redirect('/');

View File

@ -44,6 +44,10 @@ class Settings {
this.contentLanguage = 'en';
this.contentCountry = 'US';
this.sidebarOpen = false;
//Has to be local path
this.backgroundImage = null;
this.lightTheme = false;
}
//Based on electorn app.getPath
@ -121,7 +125,7 @@ class Settings {
await fs.promises.mkdir(Settings.getDir(), {recursive: true});
} catch (_) {}
await fs.promises.writeFile(Settings.getPath(), JSON.stringify(this), 'utf-8');
await fs.promises.writeFile(Settings.getPath(), JSON.stringify(this, null, 2), 'utf-8');
}
}