feat: startup/routing behavior changes if user conf doesn't exist

pull/243/head
Josh Moore 1 year ago
parent 823d2a66a6
commit 91824803a1

@ -84,7 +84,8 @@ async function main() {
app.use('/', (await import('./routers/index')).router);
// Host app
app.listen(serverConfig.port, serverConfig.host, () => log.success('Server listening', 'Ready for uploads', `click http://127.0.0.1:${serverConfig.port}`));
const userConfigExists = await fs.pathExists(path.join('userconfig.json'));
app.listen(serverConfig.port, serverConfig.host, () => log[userConfigExists ? 'success' : 'warn']('Server listening', userConfigExists ? 'Ready for uploads' : 'Setup required', `click http://127.0.0.1:${serverConfig.port}`));
}
// Launch log

@ -1,8 +1,11 @@
import fs from 'fs-extra';
import { path } from '@tycrek/joint';
import { Router, json as BodyParserJson } from 'express';
import { log } from '../log';
const router = Router({ caseSensitive: true });
const userConfigExists = fs.pathExistsSync(path.join('userconfig.json'));
router.get('/', (req, res) => res.render('index'));
router.get('/', (req, res) => userConfigExists ? res.render('index') : res.redirect('/setup'));
export { router };

Loading…
Cancel
Save