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
109 content: string | Buffer
110 write: Writable['write']
111 writeHead: Response['writeHead']
114 headers: OutgoingHttpHeaders
119 videoAPI?: MVideoFormattableDetails
120 videoAll?: MVideoFullLight
121 onlyImmutableVideo?: MVideoImmutable
122 onlyVideo?: MVideoThumbnail
125 videoLive?: MVideoLive
126 videoLiveSession?: MVideoLiveSession
128 videoShare?: MVideoShareActor
130 videoSource?: MVideoSource
132 videoFile?: MVideoFile
134 videoFileResumable?: EnhancedUploadXFile
136 videoImport?: MVideoImportDefault
138 videoBlacklist?: MVideoBlacklist
140 videoCaption?: MVideoCaptionVideo
142 abuse?: MAbuseReporter
143 abuseMessage?: MAbuseMessage
145 videoStreamingPlaylist?: MStreamingPlaylist
147 videoChannel?: MChannelBannerAccountDefault
149 videoPlaylistFull?: MVideoPlaylistFull
150 videoPlaylistSummary?: MVideoPlaylistFullSummary
152 videoPlaylistElement?: MVideoPlaylistElement
153 videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy
155 accountVideoRate?: MAccountVideoRateAccountVideo
157 videoCommentFull?: MCommentOwnerVideoReply
158 videoCommentThread?: MComment
160 follow?: MActorFollowActorsDefault
161 subscription?: MActorFollowActorsDefaultSubscription
163 nextOwner?: MAccountDefault
164 videoChangeOwnership?: MVideoChangeOwnershipFull
166 account?: MAccountDefault
169 actorFull?: MActorFull
175 videoRedundancy?: MVideoRedundancyVideo
177 accountBlock?: MAccountBlocklist
178 serverBlock?: MServerBlocklist
181 token: MOAuthTokenUser
185 actor: MActorAccountChannelId
188 authenticated?: boolean
190 registeredPlugin?: RegisteredPlugin
192 externalAuth?: RegisterServerAuthExternalOptions
196 localViewerFull?: MLocalVideoViewerWithWatchSections