]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/typings/express/index.d.ts
Resumable video uploads (#3933)
[github/Chocobozzz/PeerTube.git] / server / typings / express / index.d.ts
1 import { RegisterServerAuthExternalOptions } from '@server/types'
2 import {
3 MAbuseMessage,
4 MAbuseReporter,
5 MAccountBlocklist,
6 MActorFollowActorsDefault,
7 MActorUrl,
8 MChannelBannerAccountDefault,
9 MStreamingPlaylist,
10 MVideoChangeOwnershipFull,
11 MVideoFile,
12 MVideoImmutable,
13 MVideoLive,
14 MVideoPlaylistFull,
15 MVideoPlaylistFullSummary
16 } from '@server/types/models'
17 import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token'
18 import { MPlugin, MServer, MServerBlocklist } from '@server/types/models/server'
19 import { MVideoImportDefault } from '@server/types/models/video/video-import'
20 import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/types/models/video/video-playlist-element'
21 import { MAccountVideoRateAccountVideo } from '@server/types/models/video/video-rate'
22 import { HttpMethod } from '@shared/core-utils/miscs/http-methods'
23 import { VideoCreate } from '@shared/models'
24 import { File as UploadXFile, Metadata } from '@uploadx/core'
25 import { RegisteredPlugin } from '../../lib/plugins/plugin-manager'
26 import {
27 MAccountDefault,
28 MActorAccountChannelId,
29 MActorFollowActorsDefaultSubscription,
30 MActorFull,
31 MComment,
32 MCommentOwnerVideoReply,
33 MUserDefault,
34 MVideoBlacklist,
35 MVideoCaptionVideo,
36 MVideoFullLight,
37 MVideoIdThumbnail,
38 MVideoRedundancyVideo,
39 MVideoShareActor,
40 MVideoThumbnail,
41 MVideoWithRights
42 } from '../../types/models'
43 declare module 'express' {
44 export interface Request {
45 query: any
46 method: HttpMethod
47 }
48
49 // Upload using multer or uploadx middleware
50 export type MulterOrUploadXFile = UploadXFile | Express.Multer.File
51
52 export type UploadFiles = {
53 [fieldname: string]: MulterOrUploadXFile[]
54 } | MulterOrUploadXFile[]
55
56 // Partial object used by some functions to check the file mimetype/extension
57 export type UploadFileForCheck = {
58 originalname: string
59 mimetype: string
60 }
61
62 export type UploadFilesForCheck = {
63 [fieldname: string]: UploadFileForCheck[]
64 } | UploadFileForCheck[]
65
66 // Upload file with a duration added by our middleware
67 export type VideoUploadFile = Pick<Express.Multer.File, 'path' | 'filename' | 'size'> & {
68 duration: number
69 }
70
71 // Extends Metadata property of UploadX object
72 export type UploadXFileMetadata = Metadata & VideoCreate & {
73 previewfile: Express.Multer.File[]
74 thumbnailfile: Express.Multer.File[]
75 }
76
77 // Our custom UploadXFile object using our custom metadata
78 export type CustomUploadXFile <T extends Metadata> = UploadXFile & { metadata: T }
79
80 export type EnhancedUploadXFile = CustomUploadXFile<UploadXFileMetadata> & {
81 duration: number
82 path: string
83 filename: string
84 }
85
86 // Extends locals property from Response
87 interface Response {
88 locals: {
89 videoAll?: MVideoFullLight
90 onlyImmutableVideo?: MVideoImmutable
91 onlyVideo?: MVideoThumbnail
92 onlyVideoWithRights?: MVideoWithRights
93 videoId?: MVideoIdThumbnail
94
95 videoLive?: MVideoLive
96
97 videoShare?: MVideoShareActor
98
99 videoFile?: MVideoFile
100
101 videoFileResumable?: EnhancedUploadXFile
102
103 videoImport?: MVideoImportDefault
104
105 videoBlacklist?: MVideoBlacklist
106
107 videoCaption?: MVideoCaptionVideo
108
109 abuse?: MAbuseReporter
110 abuseMessage?: MAbuseMessage
111
112 videoStreamingPlaylist?: MStreamingPlaylist
113
114 videoChannel?: MChannelBannerAccountDefault
115
116 videoPlaylistFull?: MVideoPlaylistFull
117 videoPlaylistSummary?: MVideoPlaylistFullSummary
118
119 videoPlaylistElement?: MVideoPlaylistElement
120 videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy
121
122 accountVideoRate?: MAccountVideoRateAccountVideo
123
124 videoCommentFull?: MCommentOwnerVideoReply
125 videoCommentThread?: MComment
126
127 follow?: MActorFollowActorsDefault
128 subscription?: MActorFollowActorsDefaultSubscription
129
130 nextOwner?: MAccountDefault
131 videoChangeOwnership?: MVideoChangeOwnershipFull
132
133 account?: MAccountDefault
134
135 actorUrl?: MActorUrl
136 actorFull?: MActorFull
137
138 user?: MUserDefault
139
140 server?: MServer
141
142 videoRedundancy?: MVideoRedundancyVideo
143
144 accountBlock?: MAccountBlocklist
145 serverBlock?: MServerBlocklist
146
147 oauth?: {
148 token: MOAuthTokenUser
149 }
150
151 signature?: {
152 actor: MActorAccountChannelId
153 }
154
155 authenticated?: boolean
156
157 registeredPlugin?: RegisteredPlugin
158
159 externalAuth?: RegisterServerAuthExternalOptions
160
161 plugin?: MPlugin
162 }
163 }
164 }