2 import { OutgoingHttpHeaders } from 'http'
3 import { RegisterServerAuthExternalOptions } from '@server/types'
8 MActorFollowActorsDefault,
10 MChannelBannerAccountDefault,
12 MVideoChangeOwnershipFull,
14 MVideoFormattableDetails,
19 MVideoPlaylistFullSummary
20 } from '@server/types/models'
21 import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token'
22 import { MPlugin, MServer, MServerBlocklist } from '@server/types/models/server'
23 import { MVideoImportDefault } from '@server/types/models/video/video-import'
24 import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/types/models/video/video-playlist-element'
25 import { MAccountVideoRateAccountVideo } from '@server/types/models/video/video-rate'
26 import { HttpMethod, PeerTubeProblemDocumentData, ServerErrorCode, VideoCreate } from '@shared/models'
27 import { File as UploadXFile, Metadata } from '@uploadx/core'
28 import { RegisteredPlugin } from '../../lib/plugins/plugin-manager'
31 MActorAccountChannelId,
32 MActorFollowActorsDefaultSubscription,
35 MCommentOwnerVideoReply,
40 MVideoRedundancyVideo,
44 import { Writable } from 'stream'
45 import { MVideoSource } from './models/video/video-source'
47 declare module 'express' {
48 export interface Request {
53 // Upload using multer or uploadx middleware
54 export type MulterOrUploadXFile = UploadXFile | Express.Multer.File
56 export type UploadFiles = {
57 [fieldname: string]: MulterOrUploadXFile[]
58 } | MulterOrUploadXFile[]
60 // Partial object used by some functions to check the file mimetype/extension
61 export type UploadFileForCheck = {
67 export type UploadFilesForCheck = {
68 [fieldname: string]: UploadFileForCheck[]
69 } | UploadFileForCheck[]
71 // Upload file with a duration added by our middleware
72 export type VideoUploadFile = Pick<Express.Multer.File, 'path' | 'filename' | 'size', 'originalname'> & {
76 // Extends Metadata property of UploadX object
77 export type UploadXFileMetadata = Metadata & VideoCreate & {
78 previewfile: Express.Multer.File[]
79 thumbnailfile: Express.Multer.File[]
82 // Our custom UploadXFile object using our custom metadata
83 export type CustomUploadXFile <T extends Metadata> = UploadXFile & { metadata: T }
85 export type EnhancedUploadXFile = CustomUploadXFile<UploadXFileMetadata> & {
92 // Extends Response with added functions and potential variables passed by middlewares
99 type?: ServerErrorCode
102 data?: PeerTubeProblemDocumentData
107 content: string | Buffer
108 write: Writable['write']
109 writeHead: Response['writeHead']
112 headers: OutgoingHttpHeaders
117 videoAPI?: MVideoFormattableDetails
118 videoAll?: MVideoFullLight
119 onlyImmutableVideo?: MVideoImmutable
120 onlyVideo?: MVideoThumbnail
123 videoLive?: MVideoLive
124 videoLiveSession?: MVideoLiveSession
126 videoShare?: MVideoShareActor
128 videoSource?: MVideoSource
130 videoFile?: MVideoFile
132 videoFileResumable?: EnhancedUploadXFile
134 videoImport?: MVideoImportDefault
136 videoBlacklist?: MVideoBlacklist
138 videoCaption?: MVideoCaptionVideo
140 abuse?: MAbuseReporter
141 abuseMessage?: MAbuseMessage
143 videoStreamingPlaylist?: MStreamingPlaylist
145 videoChannel?: MChannelBannerAccountDefault
147 videoPlaylistFull?: MVideoPlaylistFull
148 videoPlaylistSummary?: MVideoPlaylistFullSummary
150 videoPlaylistElement?: MVideoPlaylistElement
151 videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy
153 accountVideoRate?: MAccountVideoRateAccountVideo
155 videoCommentFull?: MCommentOwnerVideoReply
156 videoCommentThread?: MComment
158 follow?: MActorFollowActorsDefault
159 subscription?: MActorFollowActorsDefaultSubscription
161 nextOwner?: MAccountDefault
162 videoChangeOwnership?: MVideoChangeOwnershipFull
164 account?: MAccountDefault
167 actorFull?: MActorFull
173 videoRedundancy?: MVideoRedundancyVideo
175 accountBlock?: MAccountBlocklist
176 serverBlock?: MServerBlocklist
179 token: MOAuthTokenUser
183 actor: MActorAccountChannelId
186 authenticated?: boolean
188 registeredPlugin?: RegisteredPlugin
190 externalAuth?: RegisterServerAuthExternalOptions
194 localViewerFull?: MLocalVideoViewerWithWatchSections