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