]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/types/express.d.ts
Merge branch 'release/4.2.0' into develop
[github/Chocobozzz/PeerTube.git] / server / types / express.d.ts
1
2 import { OutgoingHttpHeaders } from 'http'
3 import { RegisterServerAuthExternalOptions } from '@server/types'
4 import {
5 MAbuseMessage,
6 MAbuseReporter,
7 MAccountBlocklist,
8 MActorFollowActorsDefault,
9 MActorUrl,
10 MChannelBannerAccountDefault,
11 MStreamingPlaylist,
12 MVideoChangeOwnershipFull,
13 MVideoFile,
14 MVideoFormattableDetails,
15 MVideoId,
16 MVideoImmutable,
17 MVideoLive,
18 MVideoPlaylistFull,
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'
29 import {
30 MAccountDefault,
31 MActorAccountChannelId,
32 MActorFollowActorsDefaultSubscription,
33 MActorFull,
34 MComment,
35 MCommentOwnerVideoReply,
36 MUserDefault,
37 MVideoBlacklist,
38 MVideoCaptionVideo,
39 MVideoFullLight,
40 MVideoRedundancyVideo,
41 MVideoShareActor,
42 MVideoThumbnail
43 } from './models'
44 import { Writable } from 'stream'
45 import { MVideoSource } from './models/video/video-source'
46
47 declare module 'express' {
48 export interface Request {
49 query: any
50 method: HttpMethod
51 }
52
53 // Upload using multer or uploadx middleware
54 export type MulterOrUploadXFile = UploadXFile | Express.Multer.File
55
56 export type UploadFiles = {
57 [fieldname: string]: MulterOrUploadXFile[]
58 } | MulterOrUploadXFile[]
59
60 // Partial object used by some functions to check the file mimetype/extension
61 export type UploadFileForCheck = {
62 originalname: string
63 mimetype: string
64 size: number
65 }
66
67 export type UploadFilesForCheck = {
68 [fieldname: string]: UploadFileForCheck[]
69 } | UploadFileForCheck[]
70
71 // Upload file with a duration added by our middleware
72 export type VideoUploadFile = Pick<Express.Multer.File, 'path' | 'filename' | 'size', 'originalname'> & {
73 duration: number
74 }
75
76 // Extends Metadata property of UploadX object
77 export type UploadXFileMetadata = Metadata & VideoCreate & {
78 previewfile: Express.Multer.File[]
79 thumbnailfile: Express.Multer.File[]
80 }
81
82 // Our custom UploadXFile object using our custom metadata
83 export type CustomUploadXFile <T extends Metadata> = UploadXFile & { metadata: T }
84
85 export type EnhancedUploadXFile = CustomUploadXFile<UploadXFileMetadata> & {
86 duration: number
87 path: string
88 filename: string
89 originalname: string
90 }
91
92 // Extends Response with added functions and potential variables passed by middlewares
93 interface Response {
94 fail: (options: {
95 message: string
96
97 title?: string
98 status?: number
99 type?: ServerErrorCode
100 instance?: string
101
102 data?: PeerTubeProblemDocumentData
103 }) => void
104
105 locals: {
106 apicache: {
107 content: string | Buffer
108 write: Writable['write']
109 writeHead: Response['writeHead']
110 end: Response['end']
111 cacheable: boolean
112 headers: OutgoingHttpHeaders
113 }
114
115 docUrl?: string
116
117 videoAPI?: MVideoFormattableDetails
118 videoAll?: MVideoFullLight
119 onlyImmutableVideo?: MVideoImmutable
120 onlyVideo?: MVideoThumbnail
121 videoId?: MVideoId
122
123 videoLive?: MVideoLive
124 videoLiveSession?: MVideoLiveSession
125
126 videoShare?: MVideoShareActor
127
128 videoSource?: MVideoSource
129
130 videoFile?: MVideoFile
131
132 videoFileResumable?: EnhancedUploadXFile
133
134 videoImport?: MVideoImportDefault
135
136 videoBlacklist?: MVideoBlacklist
137
138 videoCaption?: MVideoCaptionVideo
139
140 abuse?: MAbuseReporter
141 abuseMessage?: MAbuseMessage
142
143 videoStreamingPlaylist?: MStreamingPlaylist
144
145 videoChannel?: MChannelBannerAccountDefault
146
147 videoPlaylistFull?: MVideoPlaylistFull
148 videoPlaylistSummary?: MVideoPlaylistFullSummary
149
150 videoPlaylistElement?: MVideoPlaylistElement
151 videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy
152
153 accountVideoRate?: MAccountVideoRateAccountVideo
154
155 videoCommentFull?: MCommentOwnerVideoReply
156 videoCommentThread?: MComment
157
158 follow?: MActorFollowActorsDefault
159 subscription?: MActorFollowActorsDefaultSubscription
160
161 nextOwner?: MAccountDefault
162 videoChangeOwnership?: MVideoChangeOwnershipFull
163
164 account?: MAccountDefault
165
166 actorUrl?: MActorUrl
167 actorFull?: MActorFull
168
169 user?: MUserDefault
170
171 server?: MServer
172
173 videoRedundancy?: MVideoRedundancyVideo
174
175 accountBlock?: MAccountBlocklist
176 serverBlock?: MServerBlocklist
177
178 oauth?: {
179 token: MOAuthTokenUser
180 }
181
182 signature?: {
183 actor: MActorAccountChannelId
184 }
185
186 authenticated?: boolean
187
188 registeredPlugin?: RegisteredPlugin
189
190 externalAuth?: RegisterServerAuthExternalOptions
191
192 plugin?: MPlugin
193
194 localViewerFull?: MLocalVideoViewerWithWatchSections
195 }
196 }
197 }