mirror of
https://github.com/jorisbertomeu/web-screensaver.git
synced 2026-04-19 16:27:40 +02:00
Fixes relative to fresh instance
This commit is contained in:
@@ -14,10 +14,14 @@ export class AdminController {
|
|||||||
|
|
||||||
async updateSettings(req, res, next) {
|
async updateSettings(req, res, next) {
|
||||||
try {
|
try {
|
||||||
if (req.params.hasOwnProperty('id'))
|
if (req.params.id) {
|
||||||
|
console.log('Update', req.params.id);
|
||||||
await this.db.update('settings', req.params.id, req.body);
|
await this.db.update('settings', req.params.id, req.body);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
|
console.log('Create')
|
||||||
await this.db.add('settings', req.body);
|
await this.db.add('settings', req.body);
|
||||||
|
}
|
||||||
res.json(req.body);
|
res.json(req.body);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
next(e);
|
next(e);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
import { generateRandomID } from '../utils/helper.js';
|
||||||
|
|
||||||
export class DatabaseService {
|
export class DatabaseService {
|
||||||
constructor(dbPath) {
|
constructor(dbPath) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
|
|
||||||
export const generateRandomID = (length = DEFAULT_ID_LENGTH) => {
|
export const generateRandomID = (length = 32) => {
|
||||||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
return Array.from(
|
return Array.from(
|
||||||
{ length },
|
{ length },
|
||||||
|
|||||||
Reference in New Issue
Block a user