diff options
author | 2021-09-14 19:58:52 +0200 | |
---|---|---|
committer | 2021-09-14 19:58:52 +0200 | |
commit | 95df3522a15631abc51a4295cae0ea401a8d4e1e (patch) | |
tree | e5eb0f368c947683f01458e912f21756fb0d99cb /src/internal-server/start | |
parent | docs: add sad270 as a contributor for bug, userTesting [skip ci] (#1941) (diff) | |
download | ferdium-app-95df3522a15631abc51a4295cae0ea401a8d4e1e.tar.gz ferdium-app-95df3522a15631abc51a4295cae0ea401a8d4e1e.tar.zst ferdium-app-95df3522a15631abc51a4295cae0ea401a8d4e1e.zip |
feat: add eslint-plugin-unicorn (#1936)
Diffstat (limited to 'src/internal-server/start')
-rw-r--r-- | src/internal-server/start/kernel.js | 10 | ||||
-rw-r--r-- | src/internal-server/start/migrate.js | 24 |
2 files changed, 20 insertions, 14 deletions
diff --git a/src/internal-server/start/kernel.js b/src/internal-server/start/kernel.js index 7b540f829..f72e445f2 100644 --- a/src/internal-server/start/kernel.js +++ b/src/internal-server/start/kernel.js | |||
@@ -32,8 +32,7 @@ const globalMiddleware = [ | |||
32 | | Route.get().middleware('auth') | 32 | | Route.get().middleware('auth') |
33 | | | 33 | | |
34 | */ | 34 | */ |
35 | const namedMiddleware = { | 35 | const namedMiddleware = {}; |
36 | }; | ||
37 | 36 | ||
38 | /* | 37 | /* |
39 | |-------------------------------------------------------------------------- | 38 | |-------------------------------------------------------------------------- |
@@ -45,11 +44,8 @@ const namedMiddleware = { | |||
45 | | control over request lifecycle. | 44 | | control over request lifecycle. |
46 | | | 45 | | |
47 | */ | 46 | */ |
48 | const serverMiddleware = [ | 47 | const serverMiddleware = ['Adonis/Middleware/Static']; |
49 | 'Adonis/Middleware/Static', | ||
50 | ]; | ||
51 | 48 | ||
52 | Server | 49 | Server.registerGlobal(globalMiddleware) |
53 | .registerGlobal(globalMiddleware) | ||
54 | .registerNamed(namedMiddleware) | 50 | .registerNamed(namedMiddleware) |
55 | .use(serverMiddleware); | 51 | .use(serverMiddleware); |
diff --git a/src/internal-server/start/migrate.js b/src/internal-server/start/migrate.js index c27e07bc5..0f25240cc 100644 --- a/src/internal-server/start/migrate.js +++ b/src/internal-server/start/migrate.js | |||
@@ -6,29 +6,39 @@ const { ferdiVersion } = require('../../environment'); | |||
6 | const Database = use('Database'); | 6 | const Database = use('Database'); |
7 | const User = use('App/Models/User'); | 7 | const User = use('App/Models/User'); |
8 | 8 | ||
9 | const migrateLog = (text) => { | 9 | const migrateLog = text => { |
10 | console.log('\x1b[36m%s\x1b[0m', 'Ferdi Migration:', '\x1b[0m', text); | 10 | console.log('\u001B[36m%s\u001B[0m', 'Ferdi Migration:', '\u001B[0m', text); |
11 | }; | 11 | }; |
12 | 12 | ||
13 | module.exports = async () => { | 13 | module.exports = async () => { |
14 | migrateLog('🧙 Running database migration wizard'); | 14 | migrateLog('🧙 Running database migration wizard'); |
15 | 15 | ||
16 | // Make sure user table exists | 16 | // Make sure user table exists |
17 | await Database.raw('CREATE TABLE IF NOT EXISTS `users` (`id` integer not null primary key autoincrement, `settings` text, `created_at` datetime, `updated_at` datetime);'); | 17 | await Database.raw( |
18 | 'CREATE TABLE IF NOT EXISTS `users` (`id` integer not null primary key autoincrement, `settings` text, `created_at` datetime, `updated_at` datetime);', | ||
19 | ); | ||
18 | 20 | ||
19 | const user = await User.find(1); | 21 | const user = await User.find(1); |
20 | let settings; | 22 | let settings; |
21 | if (!user) { | 23 | if (!user) { |
22 | migrateLog('🎩 Migrating from old Ferdi version as user doesn\'t exist'); | 24 | migrateLog("🎩 Migrating from old Ferdi version as user doesn't exist"); |
23 | 25 | ||
24 | // Create new user | 26 | // Create new user |
25 | await Database.raw('INSERT INTO "users" ("id") VALUES (\'1\');'); | 27 | await Database.raw('INSERT INTO "users" ("id") VALUES (\'1\');'); |
26 | } else { | 28 | } else { |
27 | settings = typeof user.settings === 'string' ? JSON.parse(user.settings) : user.settings; | 29 | settings = |
30 | typeof user.settings === 'string' | ||
31 | ? JSON.parse(user.settings) | ||
32 | : user.settings; | ||
28 | } | 33 | } |
29 | 34 | ||
30 | if (!settings || !settings.db_version || settings.db_version !== ferdiVersion) { | 35 | if ( |
31 | const srcVersion = settings && settings.db_version ? settings.db_version : '5.4.0-beta.2'; | 36 | !settings || |
37 | !settings.db_version || | ||
38 | settings.db_version !== ferdiVersion | ||
39 | ) { | ||
40 | const srcVersion = | ||
41 | settings && settings.db_version ? settings.db_version : '5.4.0-beta.2'; | ||
32 | migrateLog(`🔮 Migrating table from ${srcVersion} to ${ferdiVersion}`); | 42 | migrateLog(`🔮 Migrating table from ${srcVersion} to ${ferdiVersion}`); |
33 | 43 | ||
34 | // Migrate database to current Ferdi version | 44 | // Migrate database to current Ferdi version |