2 import { OutgoingHttpHeaders } from 'http'
3 import { RegisterServerAuthExternalOptions } from '@server/types'
8 MActorFollowActorsDefault,
10 MChannelBannerAccountDefault,
13 MVideoChangeOwnershipFull,
15 MVideoFormattableDetails,
20 MVideoPlaylistFullSummary
21 } from '@server/types/models'
22 import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token'
23 import { MPlugin, MServer, MServerBlocklist } from '@server/types/models/server'
24 import { MVideoImportDefault } from '@server/types/models/video/video-import'
25 import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/types/models/video/video-playlist-element'
26 import { MAccountVideoRateAccountVideo } from '@server/types/models/video/video-rate'
27 import { HttpMethod, PeerTubeProblemDocumentData, ServerErrorCode, VideoCreate } from '@shared/models'
28 import { File as UploadXFile, Metadata } from '@uploadx/core'
29 import { RegisteredPlugin } from '../../lib/plugins/plugin-manager'
32 MActorAccountChannelId,
33 MActorFollowActorsDefaultSubscription,
36 MCommentOwnerVideoReply,
41 MVideoRedundancyVideo,
45 import { Writable } from 'stream'
46 import { MVideoSource } from './models/video/video-source'
48 declare module 'express' {
49 export interface Request {
54 // Upload using multer or uploadx middleware
55 export type MulterOrUploadXFile = UploadXFile | Express.Multer.File
57 export type UploadFiles = {
58 [fieldname: string]: MulterOrUploadXFile[]
59 } | MulterOrUploadXFile[]
61 // Partial object used by some functions to check the file mimetype/extension
62 export type UploadFileForCheck = {
68 export type UploadFilesForCheck = {
69 [fieldname: string]: UploadFileForCheck[]
70 } | UploadFileForCheck[]
72 // Upload file with a duration added by our middleware
73 export type VideoUploadFile = Pick<Express.Multer.File, 'path' | 'filename' | 'size', 'originalname'> & {
77 // Extends Metadata property of UploadX object
78 export type UploadXFileMetadata = Metadata & VideoCreate & {
79 previewfile: Express.Multer.File[]
80 thumbnailfile: Express.Multer.File[]
83 // Our custom UploadXFile object using our custom metadata
84 export type CustomUploadXFile <T extends Metadata> = UploadXFile & { metadata: T }
86 export type EnhancedUploadXFile = CustomUploadXFile<UploadXFileMetadata> & {
93 // Extends Response with added functions and potential variables passed by middlewares
100 type?: ServerErrorCode | string
103 data?: PeerTubeProblemDocumentData
110 content: string | Buffer
111 write: Writable['write']
112 writeHead: Response['writeHead']
115 headers: OutgoingHttpHeaders
120 videoAPI?: MVideoFormattableDetails
121 videoAll?: MVideoFullLight
122 onlyImmutableVideo?: MVideoImmutable
123 onlyVideo?: MVideoThumbnail
126 videoLive?: MVideoLive
127 videoLiveSession?: MVideoLiveSession
129 videoShare?: MVideoShareActor
131 videoSource?: MVideoSource
133 videoFile?: MVideoFile
135 videoFileResumable?: EnhancedUploadXFile
137 videoImport?: MVideoImportDefault
139 videoBlacklist?: MVideoBlacklist
141 videoCaption?: MVideoCaptionVideo
143 abuse?: MAbuseReporter
144 abuseMessage?: MAbuseMessage
146 videoStreamingPlaylist?: MStreamingPlaylist
148 videoChannel?: MChannelBannerAccountDefault
149 videoChannelSync?: MChannelSyncChannel
151 videoPlaylistFull?: MVideoPlaylistFull
152 videoPlaylistSummary?: MVideoPlaylistFullSummary
154 videoPlaylistElement?: MVideoPlaylistElement
155 videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy
157 accountVideoRate?: MAccountVideoRateAccountVideo
159 videoCommentFull?: MCommentOwnerVideoReply
160 videoCommentThread?: MComment
162 follow?: MActorFollowActorsDefault
163 subscription?: MActorFollowActorsDefaultSubscription
165 nextOwner?: MAccountDefault
166 videoChangeOwnership?: MVideoChangeOwnershipFull
168 account?: MAccountDefault
171 actorFull?: MActorFull
177 videoRedundancy?: MVideoRedundancyVideo
179 accountBlock?: MAccountBlocklist
180 serverBlock?: MServerBlocklist
183 token: MOAuthTokenUser
187 actor: MActorAccountChannelId
190 authenticated?: boolean
192 registeredPlugin?: RegisteredPlugin
194 externalAuth?: RegisterServerAuthExternalOptions
198 localViewerFull?: MLocalVideoViewerWithWatchSections