Fixes relative to fresh instance

This commit is contained in:
Joris Bertomeu
2024-11-19 15:07:16 +01:00
parent 82518ea905
commit bbd4649bc2
3 changed files with 8 additions and 3 deletions

View File

@@ -14,10 +14,14 @@ export class AdminController {
async updateSettings(req, res, next) {
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);
else
}
else {
console.log('Create')
await this.db.add('settings', req.body);
}
res.json(req.body);
} catch(e) {
next(e);

View File

@@ -1,4 +1,5 @@
import fs from 'fs';
import { generateRandomID } from '../utils/helper.js';
export class DatabaseService {
constructor(dbPath) {

View File

@@ -1,6 +1,6 @@
import crypto from 'crypto';
export const generateRandomID = (length = DEFAULT_ID_LENGTH) => {
export const generateRandomID = (length = 32) => {
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
return Array.from(
{ length },