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