From 06aad80165d09a8863ab8103149a8ff518b10641 Mon Sep 17 00:00:00 2001 From: lutangar Date: Tue, 2 Nov 2021 19:11:20 +0100 Subject: chore(refactor): remove shared folder dependencies to the server Many files from the `shared` folder were importing files from the `server` folder. When attempting to use Typescript project references to describe dependencies, it highlighted a circular dependency beetween `shared` <-> `server`. The Typescript project forbid such usages. Using project references greatly improve performance by rebuilding only the updated project and not all source files. > see https://www.typescriptlang.org/docs/handbook/project-references.html --- server/controllers/api/users/token.ts | 2 +- server/controllers/api/video-playlist.ts | 2 +- server/controllers/api/videos/live.ts | 2 +- server/controllers/api/videos/upload.ts | 4 ++-- server/controllers/client.ts | 2 +- server/controllers/static.ts | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) (limited to 'server/controllers') diff --git a/server/controllers/api/users/token.ts b/server/controllers/api/users/token.ts index 1d4004ce0..42f4f6096 100644 --- a/server/controllers/api/users/token.ts +++ b/server/controllers/api/users/token.ts @@ -1,7 +1,7 @@ import express from 'express' import RateLimit from 'express-rate-limit' import { logger } from '@server/helpers/logger' -import { buildUUID } from '@server/helpers/uuid' +import { buildUUID } from '@shared/core-utils/uuid' import { CONFIG } from '@server/initializers/config' import { getAuthNameFromRefreshGrant, getBypassFromExternalAuth, getBypassFromPasswordGrant } from '@server/lib/auth/external-auth' import { handleOAuthToken } from '@server/lib/auth/oauth' diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts index 8b7a76718..f8f07b1c6 100644 --- a/server/controllers/api/video-playlist.ts +++ b/server/controllers/api/video-playlist.ts @@ -1,6 +1,6 @@ import express from 'express' import { join } from 'path' -import { uuidToShort } from '@server/helpers/uuid' +import { uuidToShort } from '@shared/core-utils/uuid' import { scheduleRefreshIfNeeded } from '@server/lib/activitypub/playlists' import { Hooks } from '@server/lib/plugins/hooks' import { getServerActor } from '@server/models/application/application' diff --git a/server/controllers/api/videos/live.ts b/server/controllers/api/videos/live.ts index 3e1480cf2..e466d041b 100644 --- a/server/controllers/api/videos/live.ts +++ b/server/controllers/api/videos/live.ts @@ -1,6 +1,6 @@ import express from 'express' import { createReqFiles } from '@server/helpers/express-utils' -import { buildUUID, uuidToShort } from '@server/helpers/uuid' +import { buildUUID, uuidToShort } from '@shared/core-utils/uuid' import { CONFIG } from '@server/initializers/config' import { ASSETS_PATH, MIMETYPES } from '@server/initializers/constants' import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.ts index 1be87f746..a4d0f980f 100644 --- a/server/controllers/api/videos/upload.ts +++ b/server/controllers/api/videos/upload.ts @@ -1,9 +1,9 @@ import express from 'express' import { move } from 'fs-extra' import { basename } from 'path' -import { getLowercaseExtension } from '@server/helpers/core-utils' +import { getLowercaseExtension } from '@shared/core-utils' import { getResumableUploadPath } from '@server/helpers/upload' -import { uuidToShort } from '@server/helpers/uuid' +import { uuidToShort } from '@shared/core-utils/uuid' import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' import { generateWebTorrentVideoFilename } from '@server/lib/paths' diff --git a/server/controllers/client.ts b/server/controllers/client.ts index 2157ae533..8a56f2f75 100644 --- a/server/controllers/client.ts +++ b/server/controllers/client.ts @@ -7,7 +7,7 @@ import { CONFIG } from '@server/initializers/config' import { Hooks } from '@server/lib/plugins/hooks' import { buildFileLocale, getCompleteLocale, is18nLocale, LOCALE_FILES } from '@shared/core-utils/i18n' import { HttpStatusCode } from '@shared/models' -import { root } from '../helpers/core-utils' +import { root } from '@shared/core-utils' import { STATIC_MAX_AGE } from '../initializers/constants' import { ClientHtml, sendHTML, serveIndexHTML } from '../lib/client-html' import { asyncMiddleware, embedCSP } from '../middlewares' diff --git a/server/controllers/static.ts b/server/controllers/static.ts index 0d94cac9b..87bceba7a 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts @@ -5,7 +5,7 @@ import { serveIndexHTML } from '@server/lib/client-html' import { ServerConfigManager } from '@server/lib/server-config-manager' import { HttpStatusCode } from '@shared/models' import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo/nodeinfo.model' -import { root } from '../helpers/core-utils' +import { root } from '@shared/core-utils' import { CONFIG, isEmailEnabled } from '../initializers/config' import { CONSTRAINTS_FIELDS, -- cgit v1.2.3