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