diff options
Diffstat (limited to 'server/helpers/utils.ts')
-rw-r--r-- | server/helpers/utils.ts | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index 39957c90f..3af14a68a 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts | |||
@@ -6,6 +6,7 @@ import { CONFIG, database as db } from '../initializers' | |||
6 | import { ResultList } from '../../shared' | 6 | import { ResultList } from '../../shared' |
7 | import { VideoResolution } from '../../shared/models/videos/video-resolution.enum' | 7 | import { VideoResolution } from '../../shared/models/videos/video-resolution.enum' |
8 | import { AccountInstance } from '../models/account/account-interface' | 8 | import { AccountInstance } from '../models/account/account-interface' |
9 | import { logger } from './logger' | ||
9 | 10 | ||
10 | function badRequest (req: express.Request, res: express.Response, next: express.NextFunction) { | 11 | function badRequest (req: express.Request, res: express.Response, next: express.NextFunction) { |
11 | return res.type('json').status(400).end() | 12 | return res.type('json').status(400).end() |
@@ -79,13 +80,18 @@ function resetSequelizeInstance (instance: Sequelize.Instance<any>, savedFields: | |||
79 | }) | 80 | }) |
80 | } | 81 | } |
81 | 82 | ||
82 | let applicationAccount: AccountInstance | 83 | let serverAccount: AccountInstance |
83 | async function getApplicationAccount () { | 84 | async function getServerAccount () { |
84 | if (applicationAccount === undefined) { | 85 | if (serverAccount === undefined) { |
85 | applicationAccount = await db.Account.loadApplication() | 86 | serverAccount = await db.Account.loadApplication() |
86 | } | 87 | } |
87 | 88 | ||
88 | return Promise.resolve(applicationAccount) | 89 | if (!serverAccount) { |
90 | logger.error('Cannot load server account.') | ||
91 | process.exit(0) | ||
92 | } | ||
93 | |||
94 | return Promise.resolve(serverAccount) | ||
89 | } | 95 | } |
90 | 96 | ||
91 | type SortType = { sortModel: any, sortValue: string } | 97 | type SortType = { sortModel: any, sortValue: string } |
@@ -99,6 +105,6 @@ export { | |||
99 | isSignupAllowed, | 105 | isSignupAllowed, |
100 | computeResolutionsToTranscode, | 106 | computeResolutionsToTranscode, |
101 | resetSequelizeInstance, | 107 | resetSequelizeInstance, |
102 | getApplicationAccount, | 108 | getServerAccount, |
103 | SortType | 109 | SortType |
104 | } | 110 | } |