]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/types/express.d.ts
Add more tracing
[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 requestStart: number
107
108 apicache: {
109 content: string | Buffer
110 write: Writable['write']
111 writeHead: Response['writeHead']
112 end: Response['end']
113 cacheable: boolean
114 headers: OutgoingHttpHeaders
115 }
116
117 docUrl?: string
118
119 videoAPI?: MVideoFormattableDetails
120 videoAll?: MVideoFullLight
121 onlyImmutableVideo?: MVideoImmutable
122 onlyVideo?: MVideoThumbnail
123 videoId?: MVideoId
124
125 videoLive?: MVideoLive
126 videoLiveSession?: MVideoLiveSession
127
128 videoShare?: MVideoShareActor
129
130 videoSource?: MVideoSource
131
132 videoFile?: MVideoFile
133
134 videoFileResumable?: EnhancedUploadXFile
135
136 videoImport?: MVideoImportDefault
137
138 videoBlacklist?: MVideoBlacklist
139
140 videoCaption?: MVideoCaptionVideo
141
142 abuse?: MAbuseReporter
143 abuseMessage?: MAbuseMessage
144
145 videoStreamingPlaylist?: MStreamingPlaylist
146
147 videoChannel?: MChannelBannerAccountDefault
148
149 videoPlaylistFull?: MVideoPlaylistFull
150 videoPlaylistSummary?: MVideoPlaylistFullSummary
151
152 videoPlaylistElement?: MVideoPlaylistElement
153 videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy
154
155 accountVideoRate?: MAccountVideoRateAccountVideo
156
157 videoCommentFull?: MCommentOwnerVideoReply
158 videoCommentThread?: MComment
159
160 follow?: MActorFollowActorsDefault
161 subscription?: MActorFollowActorsDefaultSubscription
162
163 nextOwner?: MAccountDefault
164 videoChangeOwnership?: MVideoChangeOwnershipFull
165
166 account?: MAccountDefault
167
168 actorUrl?: MActorUrl
169 actorFull?: MActorFull
170
171 user?: MUserDefault
172
173 server?: MServer
174
175 videoRedundancy?: MVideoRedundancyVideo
176
177 accountBlock?: MAccountBlocklist
178 serverBlock?: MServerBlocklist
179
180 oauth?: {
181 token: MOAuthTokenUser
182 }
183
184 signature?: {
185 actor: MActorAccountChannelId
186 }
187
188 authenticated?: boolean
189
190 registeredPlugin?: RegisteredPlugin
191
192 externalAuth?: RegisterServerAuthExternalOptions
193
194 plugin?: MPlugin
195
196 localViewerFull?: MLocalVideoViewerWithWatchSections
197 }
198 }
199 }