1 import { OutgoingHttpHeaders } from 'http'
2 import { Writable } from 'stream'
3 import { RegisterServerAuthExternalOptions } from '@server/types'
8 MActorFollowActorsDefault,
10 MChannelBannerAccountDefault,
15 MVideoChangeOwnershipFull,
17 MVideoFormattableDetails,
20 MVideoLiveFormattable,
22 MVideoPlaylistFullSummary
23 } from '@server/types/models'
24 import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token'
25 import { MPlugin, MServer, MServerBlocklist } from '@server/types/models/server'
26 import { MVideoImportDefault } from '@server/types/models/video/video-import'
27 import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/types/models/video/video-playlist-element'
28 import { MAccountVideoRateAccountVideo } from '@server/types/models/video/video-rate'
29 import { HttpMethod, PeerTubeProblemDocumentData, ServerErrorCode, VideoCreate } from '@shared/models'
30 import { File as UploadXFile, Metadata } from '@uploadx/core'
31 import { RegisteredPlugin } from '../../lib/plugins/plugin-manager'
34 MActorAccountChannelId,
35 MActorFollowActorsDefaultSubscription,
38 MCommentOwnerVideoReply,
43 MVideoRedundancyVideo,
47 import { MRunner, MRunnerJobRunner, MRunnerRegistrationToken } from './models/runners'
48 import { MVideoSource } from './models/video/video-source'
50 declare module 'express' {
51 export interface Request {
56 // Upload using multer or uploadx middleware
57 export type MulterOrUploadXFile = UploadXFile | Express.Multer.File
59 export type UploadFiles = {
60 [fieldname: string]: MulterOrUploadXFile[]
61 } | MulterOrUploadXFile[]
63 // Partial object used by some functions to check the file mimetype/extension
64 export type UploadFileForCheck = {
70 export type UploadFilesForCheck = {
71 [fieldname: string]: UploadFileForCheck[]
72 } | UploadFileForCheck[]
74 // Upload file with a duration added by our middleware
75 export type VideoUploadFile = Pick<Express.Multer.File, 'path' | 'filename' | 'size', 'originalname'> & {
79 // Extends Metadata property of UploadX object
80 export type UploadXFileMetadata = Metadata & VideoCreate & {
81 previewfile: Express.Multer.File[]
82 thumbnailfile: Express.Multer.File[]
85 // Our custom UploadXFile object using our custom metadata
86 export type CustomUploadXFile <T extends Metadata> = UploadXFile & { metadata: T }
88 export type EnhancedUploadXFile = CustomUploadXFile<UploadXFileMetadata> & {
95 // Extends Response with added functions and potential variables passed by middlewares
102 type?: ServerErrorCode | string
105 data?: PeerTubeProblemDocumentData
113 apicacheGroups: string[]
116 content: string | Buffer
117 write: Writable['write']
118 writeHead: Response['writeHead']
121 headers: OutgoingHttpHeaders
126 videoAPI?: MVideoFormattableDetails
127 videoAll?: MVideoFullLight
128 onlyImmutableVideo?: MVideoImmutable
129 onlyVideo?: MVideoThumbnail
132 videoLive?: MVideoLiveFormattable
133 videoLiveSession?: MVideoLiveSession
135 videoShare?: MVideoShareActor
137 videoSource?: MVideoSource
139 videoFile?: MVideoFile
141 videoFileResumable?: EnhancedUploadXFile
143 videoImport?: MVideoImportDefault
145 videoBlacklist?: MVideoBlacklist
147 videoCaption?: MVideoCaptionVideo
149 abuse?: MAbuseReporter
150 abuseMessage?: MAbuseMessage
152 videoStreamingPlaylist?: MStreamingPlaylist
154 videoChannel?: MChannelBannerAccountDefault
155 videoChannelSync?: MChannelSyncChannel
157 videoPlaylistFull?: MVideoPlaylistFull
158 videoPlaylistSummary?: MVideoPlaylistFullSummary
160 videoPlaylistElement?: MVideoPlaylistElement
161 videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy
163 accountVideoRate?: MAccountVideoRateAccountVideo
165 videoCommentFull?: MCommentOwnerVideoReply
166 videoCommentThread?: MComment
168 follow?: MActorFollowActorsDefault
169 subscription?: MActorFollowActorsDefaultSubscription
171 nextOwner?: MAccountDefault
172 videoChangeOwnership?: MVideoChangeOwnershipFull
174 account?: MAccountDefault
177 actorFull?: MActorFull
180 userRegistration?: MRegistration
184 videoRedundancy?: MVideoRedundancyVideo
186 accountBlock?: MAccountBlocklist
187 serverBlock?: MServerBlocklist
190 token: MOAuthTokenUser
194 actor: MActorAccountChannelId
198 user: MUserAccountUrl
201 authenticated?: boolean
203 registeredPlugin?: RegisteredPlugin
205 externalAuth?: RegisterServerAuthExternalOptions
209 localViewerFull?: MLocalVideoViewerWithWatchSections
212 runnerRegistrationToken?: MRunnerRegistrationToken
213 runnerJob?: MRunnerJobRunner