mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-03 17:59:37 +02:00
Migrate server to ESM
Sorry for the very big commit that may lead to git log issues and merge conflicts, but it's a major step forward: * Server can be faster at startup because imports() are async and we can easily lazy import big modules * Angular doesn't seem to support ES import (with .js extension), so we had to correctly organize peertube into a monorepo: * Use yarn workspace feature * Use typescript reference projects for dependencies * Shared projects have been moved into "packages", each one is now a node module (with a dedicated package.json/tsconfig.json) * server/tools have been moved into apps/ and is now a dedicated app bundled and published on NPM so users don't have to build peertube cli tools manually * server/tests have been moved into packages/ so we don't compile them every time we want to run the server * Use isolatedModule option: * Had to move from const enum to const (https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums) * Had to explictely specify "type" imports when used in decorators * Prefer tsx (that uses esbuild under the hood) instead of ts-node to load typescript files (tests with mocha or scripts): * To reduce test complexity as esbuild doesn't support decorator metadata, we only test server files that do not import server models * We still build tests files into js files for a faster CI * Remove unmaintained peertube CLI import script * Removed some barrels to speed up execution (less imports)
This commit is contained in:
parent
04d1da5621
commit
3a4992633e
2196 changed files with 12690 additions and 11574 deletions
305
packages/models/src/server/server-config.model.ts
Normal file
305
packages/models/src/server/server-config.model.ts
Normal file
|
@ -0,0 +1,305 @@
|
|||
import { ClientScriptJSON } from '../plugins/plugin-package-json.model.js'
|
||||
import { NSFWPolicyType } from '../videos/nsfw-policy.type.js'
|
||||
import { VideoPrivacyType } from '../videos/video-privacy.enum.js'
|
||||
import { BroadcastMessageLevel } from './broadcast-message-level.type.js'
|
||||
|
||||
export interface ServerConfigPlugin {
|
||||
name: string
|
||||
npmName: string
|
||||
version: string
|
||||
description: string
|
||||
clientScripts: { [name: string]: ClientScriptJSON }
|
||||
}
|
||||
|
||||
export interface ServerConfigTheme extends ServerConfigPlugin {
|
||||
css: string[]
|
||||
}
|
||||
|
||||
export interface RegisteredExternalAuthConfig {
|
||||
npmName: string
|
||||
name: string
|
||||
version: string
|
||||
authName: string
|
||||
authDisplayName: string
|
||||
}
|
||||
|
||||
export interface RegisteredIdAndPassAuthConfig {
|
||||
npmName: string
|
||||
name: string
|
||||
version: string
|
||||
authName: string
|
||||
weight: number
|
||||
}
|
||||
|
||||
export interface ServerConfig {
|
||||
serverVersion: string
|
||||
serverCommit?: string
|
||||
|
||||
client: {
|
||||
videos: {
|
||||
miniature: {
|
||||
displayAuthorAvatar: boolean
|
||||
preferAuthorDisplayName: boolean
|
||||
}
|
||||
resumableUpload: {
|
||||
maxChunkSize: number
|
||||
}
|
||||
}
|
||||
|
||||
menu: {
|
||||
login: {
|
||||
redirectOnSingleExternalAuth: boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
defaults: {
|
||||
publish: {
|
||||
downloadEnabled: boolean
|
||||
commentsEnabled: boolean
|
||||
privacy: VideoPrivacyType
|
||||
licence: number
|
||||
}
|
||||
|
||||
p2p: {
|
||||
webapp: {
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
embed: {
|
||||
enabled: boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
webadmin: {
|
||||
configuration: {
|
||||
edition: {
|
||||
allowed: boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
instance: {
|
||||
name: string
|
||||
shortDescription: string
|
||||
isNSFW: boolean
|
||||
defaultNSFWPolicy: NSFWPolicyType
|
||||
defaultClientRoute: string
|
||||
customizations: {
|
||||
javascript: string
|
||||
css: string
|
||||
}
|
||||
}
|
||||
|
||||
search: {
|
||||
remoteUri: {
|
||||
users: boolean
|
||||
anonymous: boolean
|
||||
}
|
||||
|
||||
searchIndex: {
|
||||
enabled: boolean
|
||||
url: string
|
||||
disableLocalSearch: boolean
|
||||
isDefaultSearch: boolean
|
||||
}
|
||||
}
|
||||
|
||||
plugin: {
|
||||
registered: ServerConfigPlugin[]
|
||||
|
||||
registeredExternalAuths: RegisteredExternalAuthConfig[]
|
||||
|
||||
registeredIdAndPassAuths: RegisteredIdAndPassAuthConfig[]
|
||||
}
|
||||
|
||||
theme: {
|
||||
registered: ServerConfigTheme[]
|
||||
default: string
|
||||
}
|
||||
|
||||
email: {
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
contactForm: {
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
signup: {
|
||||
allowed: boolean
|
||||
allowedForCurrentIP: boolean
|
||||
requiresEmailVerification: boolean
|
||||
requiresApproval: boolean
|
||||
minimumAge: number
|
||||
}
|
||||
|
||||
transcoding: {
|
||||
hls: {
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
web_videos: {
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
enabledResolutions: number[]
|
||||
|
||||
profile: string
|
||||
availableProfiles: string[]
|
||||
|
||||
remoteRunners: {
|
||||
enabled: boolean
|
||||
}
|
||||
}
|
||||
|
||||
live: {
|
||||
enabled: boolean
|
||||
|
||||
allowReplay: boolean
|
||||
latencySetting: {
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
maxDuration: number
|
||||
maxInstanceLives: number
|
||||
maxUserLives: number
|
||||
|
||||
transcoding: {
|
||||
enabled: boolean
|
||||
|
||||
remoteRunners: {
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
enabledResolutions: number[]
|
||||
|
||||
profile: string
|
||||
availableProfiles: string[]
|
||||
}
|
||||
|
||||
rtmp: {
|
||||
port: number
|
||||
}
|
||||
}
|
||||
|
||||
videoStudio: {
|
||||
enabled: boolean
|
||||
|
||||
remoteRunners: {
|
||||
enabled: boolean
|
||||
}
|
||||
}
|
||||
|
||||
videoFile: {
|
||||
update: {
|
||||
enabled: boolean
|
||||
}
|
||||
}
|
||||
|
||||
import: {
|
||||
videos: {
|
||||
http: {
|
||||
enabled: boolean
|
||||
}
|
||||
torrent: {
|
||||
enabled: boolean
|
||||
}
|
||||
}
|
||||
videoChannelSynchronization: {
|
||||
enabled: boolean
|
||||
}
|
||||
}
|
||||
|
||||
autoBlacklist: {
|
||||
videos: {
|
||||
ofUsers: {
|
||||
enabled: boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
avatar: {
|
||||
file: {
|
||||
size: {
|
||||
max: number
|
||||
}
|
||||
extensions: string[]
|
||||
}
|
||||
}
|
||||
|
||||
banner: {
|
||||
file: {
|
||||
size: {
|
||||
max: number
|
||||
}
|
||||
extensions: string[]
|
||||
}
|
||||
}
|
||||
|
||||
video: {
|
||||
image: {
|
||||
size: {
|
||||
max: number
|
||||
}
|
||||
extensions: string[]
|
||||
}
|
||||
file: {
|
||||
extensions: string[]
|
||||
}
|
||||
}
|
||||
|
||||
videoCaption: {
|
||||
file: {
|
||||
size: {
|
||||
max: number
|
||||
}
|
||||
extensions: string[]
|
||||
}
|
||||
}
|
||||
|
||||
user: {
|
||||
videoQuota: number
|
||||
videoQuotaDaily: number
|
||||
}
|
||||
|
||||
videoChannels: {
|
||||
maxPerUser: number
|
||||
}
|
||||
|
||||
trending: {
|
||||
videos: {
|
||||
intervalDays: number
|
||||
algorithms: {
|
||||
enabled: string[]
|
||||
default: string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tracker: {
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
followings: {
|
||||
instance: {
|
||||
autoFollowIndex: {
|
||||
indexUrl: string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
broadcastMessage: {
|
||||
enabled: boolean
|
||||
message: string
|
||||
level: BroadcastMessageLevel
|
||||
dismissable: boolean
|
||||
}
|
||||
|
||||
homepage: {
|
||||
enabled: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export type HTMLServerConfig = Omit<ServerConfig, 'signup'>
|
Loading…
Add table
Add a link
Reference in a new issue