From 9f810a8f5cfba333bd450ec63b07eb59efa02b08 Mon Sep 17 00:00:00 2001 From: Josh Moore Date: Thu, 13 Jul 2023 00:07:05 -0600 Subject: [PATCH] feat: save setup file from web setup --- backend/routers/setup.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/backend/routers/setup.ts b/backend/routers/setup.ts index 41410e0..a180ba4 100644 --- a/backend/routers/setup.ts +++ b/backend/routers/setup.ts @@ -13,22 +13,18 @@ router.get('/', (req, res) => userConfigExists() ? res.redirect('/') : res.rende router.get('/ui.js', (req, res) => userConfigExists() ? res.send('') : res.type('text').sendFile(path.join('dist-frontend/setup.mjs'))); // Setup route -router.post('/', BodyParserJson(), (req, res) => { +router.post('/', BodyParserJson(), async (req, res) => { if (userConfigExists()) return res.status(409).json({ success: false, message: 'User config already exists' }); log.debug('Setup initiated'); - // Parse body try { - const confTest = new UserConfig(req.body as UserConfiguration); - - // Temp logs - log.debug('Uploads dir', confTest.getConfig().uploadsDir); - log.debug('ID type', confTest.getConfig().idType); - log.debug('ID size', confTest.getConfig().idSize.toString()); - log.debug('Gfy size', confTest.getConfig().gfySize.toString()); - log.debug('Max file size', confTest.getConfig().maximumFileSize.toString()); + // Parse body + const userConfig = new UserConfig(req.body as UserConfiguration); + + // Save config + await userConfig.saveConfigFile(); return res.json({ success: true }); } catch (err: any) {