1 import { OutgoingHttpHeaders } from 'http'
2 import { RegisterServerAuthExternalOptions } from '@server/types'
7 MActorFollowActorsDefault,
9 MChannelBannerAccountDefault,
14 MVideoChangeOwnershipFull,
16 MVideoFormattableDetails,
21 MVideoPlaylistFullSummary
22 } from '@server/types/models'
23 import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token'
24 import { MPlugin, MServer, MServerBlocklist } from '@server/types/models/server'
25 import { MVideoImportDefault } from '@server/types/models/video/video-import'
26 import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/types/models/video/video-playlist-element'
27 import { MAccountVideoRateAccountVideo } from '@server/types/models/video/video-rate'
28 import { HttpMethod, PeerTubeProblemDocumentData, ServerErrorCode, VideoCreate } from '@shared/models'
29 import { File as UploadXFile, Metadata } from '@uploadx/core'
30 import { RegisteredPlugin } from '../../lib/plugins/plugin-manager'
33 MActorAccountChannelId,
34 MActorFollowActorsDefaultSubscription,
37 MCommentOwnerVideoReply,
42 MVideoRedundancyVideo,
46 import { Writable } from 'stream'
47 import { MVideoSource } from './models/video/video-source'
49 declare module 'express' {
50 export interface Request {
55 // Upload using multer or uploadx middleware
56 export type MulterOrUploadXFile = UploadXFile | Express.Multer.File
58 export type UploadFiles = {
59 [fieldname: string]: MulterOrUploadXFile[]
60 } | MulterOrUploadXFile[]
62 // Partial object used by some functions to check the file mimetype/extension
63 export type UploadFileForCheck = {
69 export type UploadFilesForCheck = {
70 [fieldname: string]: UploadFileForCheck[]
71 } | UploadFileForCheck[]
73 // Upload file with a duration added by our middleware
74 export type VideoUploadFile = Pick<Express.Multer.File, 'path' | 'filename' | 'size', 'originalname'> & {
78 // Extends Metadata property of UploadX object
79 export type UploadXFileMetadata = Metadata & VideoCreate & {
80 previewfile: Express.Multer.File[]
81 thumbnailfile: Express.Multer.File[]
84 // Our custom UploadXFile object using our custom metadata
85 export type CustomUploadXFile <T extends Metadata> = UploadXFile & { metadata: T }
87 export type EnhancedUploadXFile = CustomUploadXFile<UploadXFileMetadata> & {
94 // Extends Response with added functions and potential variables passed by middlewares
101 type?: ServerErrorCode | string
104 data?: PeerTubeProblemDocumentData
111 content: string | Buffer
112 write: Writable['write']
113 writeHead: Response['writeHead']
116 headers: OutgoingHttpHeaders
121 videoAPI?: MVideoFormattableDetails
122 videoAll?: MVideoFullLight
123 onlyImmutableVideo?: MVideoImmutable
124 onlyVideo?: MVideoThumbnail
127 videoLive?: MVideoLive
128 videoLiveSession?: MVideoLiveSession
130 videoShare?: MVideoShareActor
132 videoSource?: MVideoSource
134 videoFile?: MVideoFile
136 videoFileResumable?: EnhancedUploadXFile
138 videoImport?: MVideoImportDefault
140 videoBlacklist?: MVideoBlacklist
142 videoCaption?: MVideoCaptionVideo
144 abuse?: MAbuseReporter
145 abuseMessage?: MAbuseMessage
147 videoStreamingPlaylist?: MStreamingPlaylist
149 videoChannel?: MChannelBannerAccountDefault
150 videoChannelSync?: MChannelSyncChannel
152 videoPlaylistFull?: MVideoPlaylistFull
153 videoPlaylistSummary?: MVideoPlaylistFullSummary
155 videoPlaylistElement?: MVideoPlaylistElement
156 videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy
158 accountVideoRate?: MAccountVideoRateAccountVideo
160 videoCommentFull?: MCommentOwnerVideoReply
161 videoCommentThread?: MComment
163 follow?: MActorFollowActorsDefault
164 subscription?: MActorFollowActorsDefaultSubscription
166 nextOwner?: MAccountDefault
167 videoChangeOwnership?: MVideoChangeOwnershipFull
169 account?: MAccountDefault
172 actorFull?: MActorFull
175 userRegistration?: MRegistration
179 videoRedundancy?: MVideoRedundancyVideo
181 accountBlock?: MAccountBlocklist
182 serverBlock?: MServerBlocklist
185 token: MOAuthTokenUser
189 actor: MActorAccountChannelId
193 user: MUserAccountUrl
196 authenticated?: boolean
198 registeredPlugin?: RegisteredPlugin
200 externalAuth?: RegisterServerAuthExternalOptions
204 localViewerFull?: MLocalVideoViewerWithWatchSections