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