Skip to content

Commit

Permalink
feat: improve setup reliability
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Moore committed Jul 13, 2023
1 parent cb41aea commit 5cd3f57
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions backend/routers/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { path } from '@tycrek/joint';
import { Router, json as BodyParserJson } from 'express';
import { log } from '../log';
import { UserConfiguration } from 'ass';
import { UserConfig } from '../UserConfig';

const router = Router({ caseSensitive: true });
const userConfigExists = () => fs.pathExistsSync(path.join('userconfig.json'));
Expand All @@ -16,19 +17,23 @@ router.post('/', BodyParserJson(), (req, res) => {
if (userConfigExists())
return res.status(409).json({ success: false, message: 'User config already exists' });

log.debug('Running setup');
log.debug('Setup initiated');

// Parse body
const body = req.body as UserConfiguration;

// temp: print body for testing
log.debug('Uploads dir', body.uploadsDir);
log.debug('ID type', body.idType);
log.debug('ID size', body.idSize.toString());
log.debug('Gfy size', body.gfySize.toString());
log.debug('Max file size', body.maximumFileSize.toString());

return res.json({ success: true });
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());

return res.json({ success: true });
} catch (err: any) {
return res.status(400).json({ success: false, message: err.message });
}
});

export { router };

0 comments on commit 5cd3f57

Please sign in to comment.