From 74dc3bca2b14f5fd3fe80c394dfc34177a46db77 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 11 Apr 2019 14:26:41 +0200 Subject: Don't expose constants directly in initializers/ --- server/controllers/activitypub/client.ts | 2 +- server/controllers/api/config.ts | 2 +- server/controllers/api/overviews.ts | 2 +- server/controllers/api/server/follows.ts | 3 ++- server/controllers/api/server/logs.ts | 2 +- server/controllers/api/users/index.ts | 3 ++- server/controllers/api/users/me.ts | 3 ++- server/controllers/api/users/my-subscriptions.ts | 3 ++- server/controllers/api/video-channel.ts | 3 ++- server/controllers/api/video-playlist.ts | 3 ++- server/controllers/api/videos/captions.ts | 3 ++- server/controllers/api/videos/import.ts | 3 ++- server/controllers/api/videos/index.ts | 4 ++-- server/controllers/api/videos/rate.ts | 3 ++- server/controllers/bots.ts | 2 +- server/controllers/client.ts | 2 +- server/controllers/feeds.ts | 3 +-- server/controllers/services.ts | 3 +-- server/controllers/static.ts | 2 +- 19 files changed, 29 insertions(+), 22 deletions(-) (limited to 'server/controllers') diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index f47fae766..d36d10de1 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts @@ -2,7 +2,7 @@ import * as express from 'express' import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos' import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' -import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers' +import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers/constants' import { buildAnnounceWithVideoAudience, buildLikeActivity } from '../../lib/activitypub/send' import { audiencify, getAudience } from '../../lib/activitypub/audience' import { buildCreateActivity } from '../../lib/activitypub/send/send-create' diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index cdbccaa7d..40012c03b 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts @@ -4,7 +4,7 @@ import { ServerConfig, UserRight } from '../../../shared' import { About } from '../../../shared/models/server/about.model' import { CustomConfig } from '../../../shared/models/server/custom-config.model' import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup' -import { CONSTRAINTS_FIELDS } from '../../initializers' +import { CONSTRAINTS_FIELDS } from '../../initializers/constants' import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' import { customConfigUpdateValidator } from '../../middlewares/validators/config' import { ClientHtml } from '../../lib/client-html' diff --git a/server/controllers/api/overviews.ts b/server/controllers/api/overviews.ts index b052acdb7..37ac152db 100644 --- a/server/controllers/api/overviews.ts +++ b/server/controllers/api/overviews.ts @@ -4,7 +4,7 @@ import { VideoModel } from '../../models/video/video' import { asyncMiddleware } from '../../middlewares' import { TagModel } from '../../models/video/tag' import { VideosOverview } from '../../../shared/models/overviews' -import { MEMOIZE_TTL, OVERVIEWS, ROUTE_CACHE_LIFETIME } from '../../initializers' +import { MEMOIZE_TTL, OVERVIEWS, ROUTE_CACHE_LIFETIME } from '../../initializers/constants' import { cacheRoute } from '../../middlewares/cache' import * as memoizee from 'memoizee' diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts index 207a09a4c..d38ce91de 100644 --- a/server/controllers/api/server/follows.ts +++ b/server/controllers/api/server/follows.ts @@ -2,7 +2,7 @@ import * as express from 'express' import { UserRight } from '../../../../shared/models/users' import { logger } from '../../../helpers/logger' import { getFormattedObjects, getServerActor } from '../../../helpers/utils' -import { sequelizeTypescript, SERVER_ACTOR_NAME } from '../../../initializers' +import { SERVER_ACTOR_NAME } from '../../../initializers/constants' import { sendAccept, sendReject, sendUndoFollow } from '../../../lib/activitypub/send' import { asyncMiddleware, @@ -24,6 +24,7 @@ import { import { ActorFollowModel } from '../../../models/activitypub/actor-follow' import { JobQueue } from '../../../lib/job-queue' import { removeRedundancyOf } from '../../../lib/redundancy' +import { sequelizeTypescript } from '../../../initializers/database' const serverFollowsRouter = express.Router() serverFollowsRouter.get('/following', diff --git a/server/controllers/api/server/logs.ts b/server/controllers/api/server/logs.ts index bbbfa1d80..03941cca7 100644 --- a/server/controllers/api/server/logs.ts +++ b/server/controllers/api/server/logs.ts @@ -3,7 +3,7 @@ import { UserRight } from '../../../../shared/models/users' import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares' import { mtimeSortFilesDesc } from '../../../../shared/utils/logs/logs' import { readdir, readFile } from 'fs-extra' -import { MAX_LOGS_OUTPUT_CHARACTERS } from '../../../initializers' +import { MAX_LOGS_OUTPUT_CHARACTERS } from '../../../initializers/constants' import { join } from 'path' import { getLogsValidator } from '../../../middlewares/validators/logs' import { LogLevel } from '../../../../shared/models/server/log-level.type' diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts index a049e23e4..28c8de303 100644 --- a/server/controllers/api/users/index.ts +++ b/server/controllers/api/users/index.ts @@ -3,7 +3,7 @@ import * as RateLimit from 'express-rate-limit' import { UserCreate, UserRight, UserRole, UserUpdate } from '../../../../shared' import { logger } from '../../../helpers/logger' import { getFormattedObjects } from '../../../helpers/utils' -import { RATES_LIMIT, sequelizeTypescript, WEBSERVER } from '../../../initializers' +import { RATES_LIMIT, WEBSERVER } from '../../../initializers/constants' import { Emailer } from '../../../lib/emailer' import { Redis } from '../../../lib/redis' import { createUserAccountAndChannelAndPlaylist } from '../../../lib/user' @@ -44,6 +44,7 @@ import { myNotificationsRouter } from './my-notifications' import { Notifier } from '../../../lib/notifier' import { mySubscriptionsRouter } from './my-subscriptions' import { CONFIG } from '../../../initializers/config' +import { sequelizeTypescript } from '../../../initializers/database' const auditLogger = auditLoggerFactory('users') diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index 1d1588eca..ce9e78463 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts @@ -2,7 +2,7 @@ import * as express from 'express' import 'multer' import { UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../../shared' import { getFormattedObjects } from '../../../helpers/utils' -import { MIMETYPES, sequelizeTypescript } from '../../../initializers' +import { MIMETYPES } from '../../../initializers/constants' import { sendUpdateActor } from '../../../lib/activitypub/send' import { asyncMiddleware, @@ -27,6 +27,7 @@ import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../h import { VideoImportModel } from '../../../models/video/video-import' import { AccountModel } from '../../../models/account/account' import { CONFIG } from '../../../initializers/config' +import { sequelizeTypescript } from '../../../initializers/database' const auditLogger = auditLoggerFactory('users-me') diff --git a/server/controllers/api/users/my-subscriptions.ts b/server/controllers/api/users/my-subscriptions.ts index 59b906a8b..c52df3154 100644 --- a/server/controllers/api/users/my-subscriptions.ts +++ b/server/controllers/api/users/my-subscriptions.ts @@ -1,7 +1,7 @@ import * as express from 'express' import 'multer' import { getFormattedObjects } from '../../../helpers/utils' -import { sequelizeTypescript, WEBSERVER } from '../../../initializers' +import { WEBSERVER } from '../../../initializers/constants' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -20,6 +20,7 @@ import { VideoFilter } from '../../../../shared/models/videos/video-query.type' import { ActorFollowModel } from '../../../models/activitypub/actor-follow' import { JobQueue } from '../../../lib/job-queue' import { logger } from '../../../helpers/logger' +import { sequelizeTypescript } from '../../../initializers/database' const mySubscriptionsRouter = express.Router() diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts index b79ce9cec..3d6dbfe70 100644 --- a/server/controllers/api/video-channel.ts +++ b/server/controllers/api/video-channel.ts @@ -23,7 +23,7 @@ import { createVideoChannel } from '../../lib/video-channel' import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' import { setAsyncActorKeys } from '../../lib/activitypub' import { AccountModel } from '../../models/account/account' -import { MIMETYPES, sequelizeTypescript } from '../../initializers' +import { MIMETYPES } from '../../initializers/constants' import { logger } from '../../helpers/logger' import { VideoModel } from '../../models/video/video' import { updateAvatarValidator } from '../../middlewares/validators/avatar' @@ -34,6 +34,7 @@ import { JobQueue } from '../../lib/job-queue' import { VideoPlaylistModel } from '../../models/video/video-playlist' import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists' import { CONFIG } from '../../initializers/config' +import { sequelizeTypescript } from '../../initializers/database' const auditLogger = auditLoggerFactory('channels') const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts index 5a3d6a29d..71c244a60 100644 --- a/server/controllers/api/video-playlist.ts +++ b/server/controllers/api/video-playlist.ts @@ -12,7 +12,7 @@ import { } from '../../middlewares' import { videoPlaylistsSortValidator } from '../../middlewares/validators' import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' -import { MIMETYPES, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers' +import { MIMETYPES, THUMBNAILS_SIZE, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers/constants' import { logger } from '../../helpers/logger' import { resetSequelizeInstance } from '../../helpers/database-utils' import { VideoPlaylistModel } from '../../models/video/video-playlist' @@ -42,6 +42,7 @@ import { AccountModel } from '../../models/account/account' import { VideoPlaylistReorder } from '../../../shared/models/videos/playlist/video-playlist-reorder.model' import { JobQueue } from '../../lib/job-queue' import { CONFIG } from '../../initializers/config' +import { sequelizeTypescript } from '../../initializers/database' const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR }) diff --git a/server/controllers/api/videos/captions.ts b/server/controllers/api/videos/captions.ts index 7dd36e368..44c255232 100644 --- a/server/controllers/api/videos/captions.ts +++ b/server/controllers/api/videos/captions.ts @@ -2,13 +2,14 @@ import * as express from 'express' import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares' import { addVideoCaptionValidator, deleteVideoCaptionValidator, listVideoCaptionsValidator } from '../../../middlewares/validators' import { createReqFiles } from '../../../helpers/express-utils' -import { MIMETYPES, sequelizeTypescript } from '../../../initializers' +import { MIMETYPES } from '../../../initializers/constants' import { getFormattedObjects } from '../../../helpers/utils' import { VideoCaptionModel } from '../../../models/video/video-caption' import { logger } from '../../../helpers/logger' import { federateVideoIfNeeded } from '../../../lib/activitypub' import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' import { CONFIG } from '../../../initializers/config' +import { sequelizeTypescript } from '../../../initializers/database' const reqVideoCaptionAdd = createReqFiles( [ 'captionfile' ], diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index 5a8cd703e..a72b8c72e 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts @@ -3,7 +3,7 @@ import * as magnetUtil from 'magnet-uri' import 'multer' import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger' import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares' -import { MIMETYPES, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE } from '../../../initializers' +import { MIMETYPES, PREVIEWS_SIZE, THUMBNAILS_SIZE } from '../../../initializers/constants' import { getYoutubeDLInfo, YoutubeDLInfo } from '../../../helpers/youtube-dl' import { createReqFiles } from '../../../helpers/express-utils' import { logger } from '../../../helpers/logger' @@ -25,6 +25,7 @@ import { getSecureTorrentName } from '../../../helpers/utils' import { move, readFile } from 'fs-extra' import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' import { CONFIG } from '../../../initializers/config' +import { sequelizeTypescript } from '../../../initializers/database' const auditLogger = auditLoggerFactory('video-imports') const videoImportsRouter = express.Router() diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 9470afabf..d6f513254 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts @@ -10,13 +10,12 @@ import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' import { MIMETYPES, PREVIEWS_SIZE, - sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES -} from '../../../initializers' +} from '../../../initializers/constants' import { changeVideoChannelShare, federateVideoIfNeeded, @@ -61,6 +60,7 @@ import { watchingRouter } from './watching' import { Notifier } from '../../../lib/notifier' import { sendView } from '../../../lib/activitypub/send/send-view' import { CONFIG } from '../../../initializers/config' +import { sequelizeTypescript } from '../../../initializers/database' const auditLogger = auditLoggerFactory('videos') const videosRouter = express.Router() diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts index 914c596c3..b65babedf 100644 --- a/server/controllers/api/videos/rate.ts +++ b/server/controllers/api/videos/rate.ts @@ -1,11 +1,12 @@ import * as express from 'express' import { UserVideoRateUpdate } from '../../../../shared' import { logger } from '../../../helpers/logger' -import { sequelizeTypescript, VIDEO_RATE_TYPES } from '../../../initializers' +import { VIDEO_RATE_TYPES } from '../../../initializers/constants' import { getRateUrl, sendVideoRateChange } from '../../../lib/activitypub' import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoUpdateRateValidator } from '../../../middlewares' import { AccountModel } from '../../../models/account/account' import { AccountVideoRateModel } from '../../../models/account/account-video-rate' +import { sequelizeTypescript } from '../../../initializers/database' const rateVideoRouter = express.Router() diff --git a/server/controllers/bots.ts b/server/controllers/bots.ts index 58ead4799..7e8e6eff6 100644 --- a/server/controllers/bots.ts +++ b/server/controllers/bots.ts @@ -1,6 +1,6 @@ import * as express from 'express' import { asyncMiddleware } from '../middlewares' -import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers' +import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' import * as sitemapModule from 'sitemap' import { logger } from '../helpers/logger' import { VideoModel } from '../models/video/video' diff --git a/server/controllers/client.ts b/server/controllers/client.ts index ece2f460c..f51470b41 100644 --- a/server/controllers/client.ts +++ b/server/controllers/client.ts @@ -1,7 +1,7 @@ import * as express from 'express' import { join } from 'path' import { root } from '../helpers/core-utils' -import { ACCEPT_HEADERS, STATIC_MAX_AGE } from '../initializers' +import { ACCEPT_HEADERS, STATIC_MAX_AGE } from '../initializers/constants' import { asyncMiddleware, embedCSP } from '../middlewares' import { buildFileLocale, getCompleteLocale, is18nLocale, LOCALE_FILES } from '../../shared/models/i18n/i18n' import { ClientHtml } from '../lib/client-html' diff --git a/server/controllers/feeds.ts b/server/controllers/feeds.ts index 24c41d946..5064097cd 100644 --- a/server/controllers/feeds.ts +++ b/server/controllers/feeds.ts @@ -1,6 +1,5 @@ import * as express from 'express' -import { FEEDS, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' -import { THUMBNAILS_SIZE } from '../initializers' +import { FEEDS, ROUTE_CACHE_LIFETIME, THUMBNAILS_SIZE, WEBSERVER } from '../initializers/constants' import { asyncMiddleware, commonVideosFiltersValidator, diff --git a/server/controllers/services.ts b/server/controllers/services.ts index 83b01b475..c1c53c3fc 100644 --- a/server/controllers/services.ts +++ b/server/controllers/services.ts @@ -1,8 +1,7 @@ import * as express from 'express' -import { EMBED_SIZE, PREVIEWS_SIZE, WEBSERVER } from '../initializers' +import { EMBED_SIZE, PREVIEWS_SIZE, WEBSERVER } from '../initializers/constants' import { asyncMiddleware, oembedValidator } from '../middlewares' import { accountNameWithHostGetValidator } from '../middlewares/validators' -import { CONFIG } from '../initializers/config' const servicesRouter = express.Router() diff --git a/server/controllers/static.ts b/server/controllers/static.ts index be5fcc8ed..f6bb88725 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts @@ -7,7 +7,7 @@ import { STATIC_MAX_AGE, STATIC_PATHS, WEBSERVER -} from '../initializers' +} from '../initializers/constants' import { VideosCaptionCache, VideosPreviewCache } from '../lib/files-cache' import { cacheRoute } from '../middlewares/cache' import { asyncMiddleware, videosGetValidator } from '../middlewares' -- cgit v1.2.3