diff options
author | Chocobozzz <me@florianbigard.com> | 2023-07-31 14:34:36 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-08-11 15:02:33 +0200 |
commit | 3a4992633ee62d5edfbb484d9c6bcb3cf158489d (patch) | |
tree | e4510b39bdac9c318fdb4b47018d08f15368b8f0 /packages/models/src/server/server-config.model.ts | |
parent | 04d1da5621d25d59bd5fa1543b725c497bf5d9a8 (diff) | |
download | PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.tar.gz PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.tar.zst PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.zip |
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)
Diffstat (limited to 'packages/models/src/server/server-config.model.ts')
-rw-r--r-- | packages/models/src/server/server-config.model.ts | 305 |
1 files changed, 305 insertions, 0 deletions
diff --git a/packages/models/src/server/server-config.model.ts b/packages/models/src/server/server-config.model.ts new file mode 100644 index 000000000..a2a2bd5aa --- /dev/null +++ b/packages/models/src/server/server-config.model.ts | |||
@@ -0,0 +1,305 @@ | |||
1 | import { ClientScriptJSON } from '../plugins/plugin-package-json.model.js' | ||
2 | import { NSFWPolicyType } from '../videos/nsfw-policy.type.js' | ||
3 | import { VideoPrivacyType } from '../videos/video-privacy.enum.js' | ||
4 | import { BroadcastMessageLevel } from './broadcast-message-level.type.js' | ||
5 | |||
6 | export interface ServerConfigPlugin { | ||
7 | name: string | ||
8 | npmName: string | ||
9 | version: string | ||
10 | description: string | ||
11 | clientScripts: { [name: string]: ClientScriptJSON } | ||
12 | } | ||
13 | |||
14 | export interface ServerConfigTheme extends ServerConfigPlugin { | ||
15 | css: string[] | ||
16 | } | ||
17 | |||
18 | export interface RegisteredExternalAuthConfig { | ||
19 | npmName: string | ||
20 | name: string | ||
21 | version: string | ||
22 | authName: string | ||
23 | authDisplayName: string | ||
24 | } | ||
25 | |||
26 | export interface RegisteredIdAndPassAuthConfig { | ||
27 | npmName: string | ||
28 | name: string | ||
29 | version: string | ||
30 | authName: string | ||
31 | weight: number | ||
32 | } | ||
33 | |||
34 | export interface ServerConfig { | ||
35 | serverVersion: string | ||
36 | serverCommit?: string | ||
37 | |||
38 | client: { | ||
39 | videos: { | ||
40 | miniature: { | ||
41 | displayAuthorAvatar: boolean | ||
42 | preferAuthorDisplayName: boolean | ||
43 | } | ||
44 | resumableUpload: { | ||
45 | maxChunkSize: number | ||
46 | } | ||
47 | } | ||
48 | |||
49 | menu: { | ||
50 | login: { | ||
51 | redirectOnSingleExternalAuth: boolean | ||
52 | } | ||
53 | } | ||
54 | } | ||
55 | |||
56 | defaults: { | ||
57 | publish: { | ||
58 | downloadEnabled: boolean | ||
59 | commentsEnabled: boolean | ||
60 | privacy: VideoPrivacyType | ||
61 | licence: number | ||
62 | } | ||
63 | |||
64 | p2p: { | ||
65 | webapp: { | ||
66 | enabled: boolean | ||
67 | } | ||
68 | |||
69 | embed: { | ||
70 | enabled: boolean | ||
71 | } | ||
72 | } | ||
73 | } | ||
74 | |||
75 | webadmin: { | ||
76 | configuration: { | ||
77 | edition: { | ||
78 | allowed: boolean | ||
79 | } | ||
80 | } | ||
81 | } | ||
82 | |||
83 | instance: { | ||
84 | name: string | ||
85 | shortDescription: string | ||
86 | isNSFW: boolean | ||
87 | defaultNSFWPolicy: NSFWPolicyType | ||
88 | defaultClientRoute: string | ||
89 | customizations: { | ||
90 | javascript: string | ||
91 | css: string | ||
92 | } | ||
93 | } | ||
94 | |||
95 | search: { | ||
96 | remoteUri: { | ||
97 | users: boolean | ||
98 | anonymous: boolean | ||
99 | } | ||
100 | |||
101 | searchIndex: { | ||
102 | enabled: boolean | ||
103 | url: string | ||
104 | disableLocalSearch: boolean | ||
105 | isDefaultSearch: boolean | ||
106 | } | ||
107 | } | ||
108 | |||
109 | plugin: { | ||
110 | registered: ServerConfigPlugin[] | ||
111 | |||
112 | registeredExternalAuths: RegisteredExternalAuthConfig[] | ||
113 | |||
114 | registeredIdAndPassAuths: RegisteredIdAndPassAuthConfig[] | ||
115 | } | ||
116 | |||
117 | theme: { | ||
118 | registered: ServerConfigTheme[] | ||
119 | default: string | ||
120 | } | ||
121 | |||
122 | email: { | ||
123 | enabled: boolean | ||
124 | } | ||
125 | |||
126 | contactForm: { | ||
127 | enabled: boolean | ||
128 | } | ||
129 | |||
130 | signup: { | ||
131 | allowed: boolean | ||
132 | allowedForCurrentIP: boolean | ||
133 | requiresEmailVerification: boolean | ||
134 | requiresApproval: boolean | ||
135 | minimumAge: number | ||
136 | } | ||
137 | |||
138 | transcoding: { | ||
139 | hls: { | ||
140 | enabled: boolean | ||
141 | } | ||
142 | |||
143 | web_videos: { | ||
144 | enabled: boolean | ||
145 | } | ||
146 | |||
147 | enabledResolutions: number[] | ||
148 | |||
149 | profile: string | ||
150 | availableProfiles: string[] | ||
151 | |||
152 | remoteRunners: { | ||
153 | enabled: boolean | ||
154 | } | ||
155 | } | ||
156 | |||
157 | live: { | ||
158 | enabled: boolean | ||
159 | |||
160 | allowReplay: boolean | ||
161 | latencySetting: { | ||
162 | enabled: boolean | ||
163 | } | ||
164 | |||
165 | maxDuration: number | ||
166 | maxInstanceLives: number | ||
167 | maxUserLives: number | ||
168 | |||
169 | transcoding: { | ||
170 | enabled: boolean | ||
171 | |||
172 | remoteRunners: { | ||
173 | enabled: boolean | ||
174 | } | ||
175 | |||
176 | enabledResolutions: number[] | ||
177 | |||
178 | profile: string | ||
179 | availableProfiles: string[] | ||
180 | } | ||
181 | |||
182 | rtmp: { | ||
183 | port: number | ||
184 | } | ||
185 | } | ||
186 | |||
187 | videoStudio: { | ||
188 | enabled: boolean | ||
189 | |||
190 | remoteRunners: { | ||
191 | enabled: boolean | ||
192 | } | ||
193 | } | ||
194 | |||
195 | videoFile: { | ||
196 | update: { | ||
197 | enabled: boolean | ||
198 | } | ||
199 | } | ||
200 | |||
201 | import: { | ||
202 | videos: { | ||
203 | http: { | ||
204 | enabled: boolean | ||
205 | } | ||
206 | torrent: { | ||
207 | enabled: boolean | ||
208 | } | ||
209 | } | ||
210 | videoChannelSynchronization: { | ||
211 | enabled: boolean | ||
212 | } | ||
213 | } | ||
214 | |||
215 | autoBlacklist: { | ||
216 | videos: { | ||
217 | ofUsers: { | ||
218 | enabled: boolean | ||
219 | } | ||
220 | } | ||
221 | } | ||
222 | |||
223 | avatar: { | ||
224 | file: { | ||
225 | size: { | ||
226 | max: number | ||
227 | } | ||
228 | extensions: string[] | ||
229 | } | ||
230 | } | ||
231 | |||
232 | banner: { | ||
233 | file: { | ||
234 | size: { | ||
235 | max: number | ||
236 | } | ||
237 | extensions: string[] | ||
238 | } | ||
239 | } | ||
240 | |||
241 | video: { | ||
242 | image: { | ||
243 | size: { | ||
244 | max: number | ||
245 | } | ||
246 | extensions: string[] | ||
247 | } | ||
248 | file: { | ||
249 | extensions: string[] | ||
250 | } | ||
251 | } | ||
252 | |||
253 | videoCaption: { | ||
254 | file: { | ||
255 | size: { | ||
256 | max: number | ||
257 | } | ||
258 | extensions: string[] | ||
259 | } | ||
260 | } | ||
261 | |||
262 | user: { | ||
263 | videoQuota: number | ||
264 | videoQuotaDaily: number | ||
265 | } | ||
266 | |||
267 | videoChannels: { | ||
268 | maxPerUser: number | ||
269 | } | ||
270 | |||
271 | trending: { | ||
272 | videos: { | ||
273 | intervalDays: number | ||
274 | algorithms: { | ||
275 | enabled: string[] | ||
276 | default: string | ||
277 | } | ||
278 | } | ||
279 | } | ||
280 | |||
281 | tracker: { | ||
282 | enabled: boolean | ||
283 | } | ||
284 | |||
285 | followings: { | ||
286 | instance: { | ||
287 | autoFollowIndex: { | ||
288 | indexUrl: string | ||
289 | } | ||
290 | } | ||
291 | } | ||
292 | |||
293 | broadcastMessage: { | ||
294 | enabled: boolean | ||
295 | message: string | ||
296 | level: BroadcastMessageLevel | ||
297 | dismissable: boolean | ||
298 | } | ||
299 | |||
300 | homepage: { | ||
301 | enabled: boolean | ||
302 | } | ||
303 | } | ||
304 | |||
305 | export type HTMLServerConfig = Omit<ServerConfig, 'signup'> | ||