+
import { RegisterServerAuthExternalOptions } from '@server/types'
import {
MAbuseMessage,
MStreamingPlaylist,
MVideoChangeOwnershipFull,
MVideoFile,
+ MVideoFormattableDetails,
MVideoImmutable,
MVideoLive,
MVideoPlaylistFull,
import { MVideoImportDefault } from '@server/types/models/video/video-import'
import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/types/models/video/video-playlist-element'
import { MAccountVideoRateAccountVideo } from '@server/types/models/video/video-rate'
+import { HttpMethod } from '@shared/core-utils/miscs/http-methods'
+import { PeerTubeProblemDocumentData, ServerErrorCode, VideoCreate } from '@shared/models'
+import { File as UploadXFile, Metadata } from '@uploadx/core'
import { RegisteredPlugin } from '../../lib/plugins/plugin-manager'
import {
MAccountDefault,
declare module 'express' {
export interface Request {
query: any
+ method: HttpMethod
}
- interface Response {
- locals: PeerTubeLocals
+
+ // Upload using multer or uploadx middleware
+ export type MulterOrUploadXFile = UploadXFile | Express.Multer.File
+
+ export type UploadFiles = {
+ [fieldname: string]: MulterOrUploadXFile[]
+ } | MulterOrUploadXFile[]
+
+ // Partial object used by some functions to check the file mimetype/extension
+ export type UploadFileForCheck = {
+ originalname: string
+ mimetype: string
}
-}
-interface PeerTubeLocals {
- videoAll?: MVideoFullLight
- onlyImmutableVideo?: MVideoImmutable
- onlyVideo?: MVideoThumbnail
- onlyVideoWithRights?: MVideoWithRights
- videoId?: MVideoIdThumbnail
+ export type UploadFilesForCheck = {
+ [fieldname: string]: UploadFileForCheck[]
+ } | UploadFileForCheck[]
- videoLive?: MVideoLive
+ // Upload file with a duration added by our middleware
+ export type VideoUploadFile = Pick<Express.Multer.File, 'path' | 'filename' | 'size'> & {
+ duration: number
+ }
- videoShare?: MVideoShareActor
+ // Extends Metadata property of UploadX object
+ export type UploadXFileMetadata = Metadata & VideoCreate & {
+ previewfile: Express.Multer.File[]
+ thumbnailfile: Express.Multer.File[]
+ }
- videoFile?: MVideoFile
+ // Our custom UploadXFile object using our custom metadata
+ export type CustomUploadXFile <T extends Metadata> = UploadXFile & { metadata: T }
- videoImport?: MVideoImportDefault
+ export type EnhancedUploadXFile = CustomUploadXFile<UploadXFileMetadata> & {
+ duration: number
+ path: string
+ filename: string
+ }
- videoBlacklist?: MVideoBlacklist
+ // Extends Response with added functions and potential variables passed by middlewares
+ interface Response {
+ fail: (options: {
+ message: string
- videoCaption?: MVideoCaptionVideo
+ title?: string
+ status?: number
+ type?: ServerErrorCode
+ instance?: string
- abuse?: MAbuseReporter
- abuseMessage?: MAbuseMessage
+ data?: PeerTubeProblemDocumentData
+ }) => void
- videoStreamingPlaylist?: MStreamingPlaylist
+ locals: {
+ docUrl?: string
- videoChannel?: MChannelBannerAccountDefault
+ videoAPI?: MVideoFormattableDetails
+ videoAll?: MVideoFullLight
+ onlyImmutableVideo?: MVideoImmutable
+ onlyVideo?: MVideoThumbnail
+ onlyVideoWithRights?: MVideoWithRights
+ videoId?: MVideoIdThumbnail
- videoPlaylistFull?: MVideoPlaylistFull
- videoPlaylistSummary?: MVideoPlaylistFullSummary
+ videoLive?: MVideoLive
- videoPlaylistElement?: MVideoPlaylistElement
- videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy
+ videoShare?: MVideoShareActor
- accountVideoRate?: MAccountVideoRateAccountVideo
+ videoFile?: MVideoFile
- videoCommentFull?: MCommentOwnerVideoReply
- videoCommentThread?: MComment
+ videoFileResumable?: EnhancedUploadXFile
- follow?: MActorFollowActorsDefault
- subscription?: MActorFollowActorsDefaultSubscription
+ videoImport?: MVideoImportDefault
- nextOwner?: MAccountDefault
- videoChangeOwnership?: MVideoChangeOwnershipFull
+ videoBlacklist?: MVideoBlacklist
- account?: MAccountDefault
+ videoCaption?: MVideoCaptionVideo
- actorUrl?: MActorUrl
- actorFull?: MActorFull
+ abuse?: MAbuseReporter
+ abuseMessage?: MAbuseMessage
- user?: MUserDefault
+ videoStreamingPlaylist?: MStreamingPlaylist
- server?: MServer
+ videoChannel?: MChannelBannerAccountDefault
- videoRedundancy?: MVideoRedundancyVideo
+ videoPlaylistFull?: MVideoPlaylistFull
+ videoPlaylistSummary?: MVideoPlaylistFullSummary
- accountBlock?: MAccountBlocklist
- serverBlock?: MServerBlocklist
+ videoPlaylistElement?: MVideoPlaylistElement
+ videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy
- oauth?: {
- token: MOAuthTokenUser
- }
+ accountVideoRate?: MAccountVideoRateAccountVideo
- signature?: {
- actor: MActorAccountChannelId
- }
+ videoCommentFull?: MCommentOwnerVideoReply
+ videoCommentThread?: MComment
- authenticated?: boolean
+ follow?: MActorFollowActorsDefault
+ subscription?: MActorFollowActorsDefaultSubscription
- registeredPlugin?: RegisteredPlugin
+ nextOwner?: MAccountDefault
+ videoChangeOwnership?: MVideoChangeOwnershipFull
- externalAuth?: RegisterServerAuthExternalOptions
+ account?: MAccountDefault
- plugin?: MPlugin
+ actorUrl?: MActorUrl
+ actorFull?: MActorFull
+
+ user?: MUserDefault
+
+ server?: MServer
+
+ videoRedundancy?: MVideoRedundancyVideo
+
+ accountBlock?: MAccountBlocklist
+ serverBlock?: MServerBlocklist
+
+ oauth?: {
+ token: MOAuthTokenUser
+ }
+
+ signature?: {
+ actor: MActorAccountChannelId
+ }
+
+ authenticated?: boolean
+
+ registeredPlugin?: RegisteredPlugin
+
+ externalAuth?: RegisterServerAuthExternalOptions
+
+ plugin?: MPlugin
+ }
+ }
}