diff --git a/components/admin/Settings.vue b/components/admin/Settings.vue index f0bd6997..0a084508 100644 --- a/components/admin/Settings.vue +++ b/components/admin/Settings.vue @@ -83,7 +83,7 @@ export default { computed: { ...mapState(['settings']), showSMTPAlert () { - return !this.setup && !this.settings.admin_email && !this.settings.smtp && !this.settings.smtp.host && !this.settings.smtp.user + return !this.setup && (!this.settings.admin_email || !this.settings.smtp || !this.settings.smtp.host || !this.settings.smtp.user) }, instance_locale: { get () { return this.settings.instance_locale }, diff --git a/server/api/index.js b/server/api/index.js index 4b87de93..5294971a 100644 --- a/server/api/index.js +++ b/server/api/index.js @@ -21,7 +21,6 @@ if (config.firstrun) { } else { - const { isAuth, isAdmin } = require('./auth') const eventController = require('./controller/event') const settingsController = require('./controller/settings') diff --git a/server/api/models/index.js b/server/api/models/index.js index b0cd7cca..624277ee 100644 --- a/server/api/models/index.js +++ b/server/api/models/index.js @@ -38,18 +38,18 @@ const db = { } }) return await umzug.up() - } -} - -if (!config.firstrun) { - try { - db.connect().then(e => { - log.debug('Running migrations') - db.runMigrations() - }) - } catch (e) { - log.warn(` ⚠️ Cannot connect to db, check your configuration => ${e}`) - process.exit(1) + }, + async initialize () { + if (!config.firstrun) { + try { + await db.connect() + log.debug('Running migrations') + return db.runMigrations() + } catch (e) { + log.warn(` ⚠️ Cannot connect to db, check your configuration => ${e}`) + process.exit(1) + } + } } } diff --git a/server/initialize.server.js b/server/initialize.server.js index e94d149a..789491a9 100644 --- a/server/initialize.server.js +++ b/server/initialize.server.js @@ -1,13 +1,13 @@ -export default function () { - async function start (nuxt) { +export default async function () { const log = require('../server/log') const config = require('../server/config') const settingsController = require('./api/controller/settings') const dayjs = require('dayjs') const timezone = require('dayjs/plugin/timezone') + const db = require('./api/models/index') dayjs.extend(timezone) - + await db.initialize() await settingsController.load() dayjs.tz.setDefault(settingsController.settings.instance_timezone) @@ -26,11 +26,8 @@ export default function () { await sequelize.close() process.off('SIGTERM', shutdown) process.off('SIGINT', shutdown) - nuxt.close() process.exit() } process.on('SIGTERM', shutdown) process.on('SIGINT', shutdown) - } - this.nuxt.hook('listen', start) }