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