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
123 videoShare?: MVideoShareActor
125 videoFile?: MVideoFile
127 videoFileResumable?: EnhancedUploadXFile
129 videoImport?: MVideoImportDefault
131 videoBlacklist?: MVideoBlacklist
133 videoCaption?: MVideoCaptionVideo
135 abuse?: MAbuseReporter
136 abuseMessage?: MAbuseMessage
138 videoStreamingPlaylist?: MStreamingPlaylist
140 videoChannel?: MChannelBannerAccountDefault
142 videoPlaylistFull?: MVideoPlaylistFull
143 videoPlaylistSummary?: MVideoPlaylistFullSummary
145 videoPlaylistElement?: MVideoPlaylistElement
146 videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy
148 accountVideoRate?: MAccountVideoRateAccountVideo
150 videoCommentFull?: MCommentOwnerVideoReply
151 videoCommentThread?: MComment
153 follow?: MActorFollowActorsDefault
154 subscription?: MActorFollowActorsDefaultSubscription
156 nextOwner?: MAccountDefault
157 videoChangeOwnership?: MVideoChangeOwnershipFull
159 account?: MAccountDefault
162 actorFull?: MActorFull
168 videoRedundancy?: MVideoRedundancyVideo
170 accountBlock?: MAccountBlocklist
171 serverBlock?: MServerBlocklist
174 token: MOAuthTokenUser
178 actor: MActorAccountChannelId
181 authenticated?: boolean
183 registeredPlugin?: RegisteredPlugin
185 externalAuth?: RegisterServerAuthExternalOptions
189 localViewerFull?: MLocalVideoViewerWithWatchSections