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'
46 declare module 'express' {
47 export interface Request {
52 // Upload using multer or uploadx middleware
53 export type MulterOrUploadXFile = UploadXFile | Express.Multer.File
55 export type UploadFiles = {
56 [fieldname: string]: MulterOrUploadXFile[]
57 } | MulterOrUploadXFile[]
59 // Partial object used by some functions to check the file mimetype/extension
60 export type UploadFileForCheck = {
66 export type UploadFilesForCheck = {
67 [fieldname: string]: UploadFileForCheck[]
68 } | UploadFileForCheck[]
70 // Upload file with a duration added by our middleware
71 export type VideoUploadFile = Pick<Express.Multer.File, 'path' | 'filename' | 'size'> & {
75 // Extends Metadata property of UploadX object
76 export type UploadXFileMetadata = Metadata & VideoCreate & {
77 previewfile: Express.Multer.File[]
78 thumbnailfile: Express.Multer.File[]
81 // Our custom UploadXFile object using our custom metadata
82 export type CustomUploadXFile <T extends Metadata> = UploadXFile & { metadata: T }
84 export type EnhancedUploadXFile = CustomUploadXFile<UploadXFileMetadata> & {
90 // Extends Response with added functions and potential variables passed by middlewares
97 type?: ServerErrorCode
100 data?: PeerTubeProblemDocumentData
105 content: string | Buffer
106 write: Writable['write']
107 writeHead: Response['writeHead']
110 headers: OutgoingHttpHeaders
115 videoAPI?: MVideoFormattableDetails
116 videoAll?: MVideoFullLight
117 onlyImmutableVideo?: MVideoImmutable
118 onlyVideo?: MVideoThumbnail
121 videoLive?: MVideoLive
122 videoLiveSession?: MVideoLiveSession
124 videoShare?: MVideoShareActor
126 videoFile?: MVideoFile
128 videoFileResumable?: EnhancedUploadXFile
130 videoImport?: MVideoImportDefault
132 videoBlacklist?: MVideoBlacklist
134 videoCaption?: MVideoCaptionVideo
136 abuse?: MAbuseReporter
137 abuseMessage?: MAbuseMessage
139 videoStreamingPlaylist?: MStreamingPlaylist
141 videoChannel?: MChannelBannerAccountDefault
143 videoPlaylistFull?: MVideoPlaylistFull
144 videoPlaylistSummary?: MVideoPlaylistFullSummary
146 videoPlaylistElement?: MVideoPlaylistElement
147 videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy
149 accountVideoRate?: MAccountVideoRateAccountVideo
151 videoCommentFull?: MCommentOwnerVideoReply
152 videoCommentThread?: MComment
154 follow?: MActorFollowActorsDefault
155 subscription?: MActorFollowActorsDefaultSubscription
157 nextOwner?: MAccountDefault
158 videoChangeOwnership?: MVideoChangeOwnershipFull
160 account?: MAccountDefault
163 actorFull?: MActorFull
169 videoRedundancy?: MVideoRedundancyVideo
171 accountBlock?: MAccountBlocklist
172 serverBlock?: MServerBlocklist
175 token: MOAuthTokenUser
179 actor: MActorAccountChannelId
182 authenticated?: boolean
184 registeredPlugin?: RegisteredPlugin
186 externalAuth?: RegisterServerAuthExternalOptions
190 localViewerFull?: MLocalVideoViewerWithWatchSections