]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/typings/express/index.d.ts
f58436ce1e406d6db9d3ec152c9383a58bf0a781
[github/Chocobozzz/PeerTube.git] / server / typings / express / index.d.ts
1 import { RegisterServerAuthExternalOptions } from '@server/types'
2 import {
3 MAbuseMessage,
4 MAbuseReporter,
5 MAccountBlocklist,
6 MActorFollowActorsDefault,
7 MActorUrl,
8 MChannelBannerAccountDefault,
9 MStreamingPlaylist,
10 MVideoChangeOwnershipFull,
11 MVideoFile,
12 MVideoImmutable,
13 MVideoLive,
14 MVideoPlaylistFull,
15 MVideoPlaylistFullSummary
16 } from '@server/types/models'
17 import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token'
18 import { MPlugin, MServer, MServerBlocklist } from '@server/types/models/server'
19 import { MVideoImportDefault } from '@server/types/models/video/video-import'
20 import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/types/models/video/video-playlist-element'
21 import { MAccountVideoRateAccountVideo } from '@server/types/models/video/video-rate'
22 import { HttpMethod } from '@shared/core-utils/miscs/http-methods'
23 import { VideoCreate } from '@shared/models'
24 import { File as UploadXFile, Metadata } from '@uploadx/core'
25 import { ProblemDocumentOptions } from 'http-problem-details/dist/ProblemDocument'
26 import { RegisteredPlugin } from '../../lib/plugins/plugin-manager'
27 import {
28 MAccountDefault,
29 MActorAccountChannelId,
30 MActorFollowActorsDefaultSubscription,
31 MActorFull,
32 MComment,
33 MCommentOwnerVideoReply,
34 MUserDefault,
35 MVideoBlacklist,
36 MVideoCaptionVideo,
37 MVideoFullLight,
38 MVideoIdThumbnail,
39 MVideoRedundancyVideo,
40 MVideoShareActor,
41 MVideoThumbnail,
42 MVideoWithRights
43 } from '../../types/models'
44 declare module 'express' {
45 export interface Request {
46 query: any
47 method: HttpMethod
48 }
49
50 // Upload using multer or uploadx middleware
51 export type MulterOrUploadXFile = UploadXFile | Express.Multer.File
52
53 export type UploadFiles = {
54 [fieldname: string]: MulterOrUploadXFile[]
55 } | MulterOrUploadXFile[]
56
57 // Partial object used by some functions to check the file mimetype/extension
58 export type UploadFileForCheck = {
59 originalname: string
60 mimetype: string
61 }
62
63 export type UploadFilesForCheck = {
64 [fieldname: string]: UploadFileForCheck[]
65 } | UploadFileForCheck[]
66
67 // Upload file with a duration added by our middleware
68 export type VideoUploadFile = Pick<Express.Multer.File, 'path' | 'filename' | 'size'> & {
69 duration: number
70 }
71
72 // Extends Metadata property of UploadX object
73 export type UploadXFileMetadata = Metadata & VideoCreate & {
74 previewfile: Express.Multer.File[]
75 thumbnailfile: Express.Multer.File[]
76 }
77
78 // Our custom UploadXFile object using our custom metadata
79 export type CustomUploadXFile <T extends Metadata> = UploadXFile & { metadata: T }
80
81 export type EnhancedUploadXFile = CustomUploadXFile<UploadXFileMetadata> & {
82 duration: number
83 path: string
84 filename: string
85 }
86
87 // Extends Response with added functions and potential variables passed by middlewares
88 interface Response {
89 docs?: string
90 fail: (options: {
91 data?: Record<string, Object>
92 docs?: string
93 message: string
94 } & ProblemDocumentOptions) => void
95
96 locals: {
97 videoAll?: MVideoFullLight
98 onlyImmutableVideo?: MVideoImmutable
99 onlyVideo?: MVideoThumbnail
100 onlyVideoWithRights?: MVideoWithRights
101 videoId?: MVideoIdThumbnail
102
103 videoLive?: MVideoLive
104
105 videoShare?: MVideoShareActor
106
107 videoFile?: MVideoFile
108
109 videoFileResumable?: EnhancedUploadXFile
110
111 videoImport?: MVideoImportDefault
112
113 videoBlacklist?: MVideoBlacklist
114
115 videoCaption?: MVideoCaptionVideo
116
117 abuse?: MAbuseReporter
118 abuseMessage?: MAbuseMessage
119
120 videoStreamingPlaylist?: MStreamingPlaylist
121
122 videoChannel?: MChannelBannerAccountDefault
123
124 videoPlaylistFull?: MVideoPlaylistFull
125 videoPlaylistSummary?: MVideoPlaylistFullSummary
126
127 videoPlaylistElement?: MVideoPlaylistElement
128 videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy
129
130 accountVideoRate?: MAccountVideoRateAccountVideo
131
132 videoCommentFull?: MCommentOwnerVideoReply
133 videoCommentThread?: MComment
134
135 follow?: MActorFollowActorsDefault
136 subscription?: MActorFollowActorsDefaultSubscription
137
138 nextOwner?: MAccountDefault
139 videoChangeOwnership?: MVideoChangeOwnershipFull
140
141 account?: MAccountDefault
142
143 actorUrl?: MActorUrl
144 actorFull?: MActorFull
145
146 user?: MUserDefault
147
148 server?: MServer
149
150 videoRedundancy?: MVideoRedundancyVideo
151
152 accountBlock?: MAccountBlocklist
153 serverBlock?: MServerBlocklist
154
155 oauth?: {
156 token: MOAuthTokenUser
157 }
158
159 signature?: {
160 actor: MActorAccountChannelId
161 }
162
163 authenticated?: boolean
164
165 registeredPlugin?: RegisteredPlugin
166
167 externalAuth?: RegisterServerAuthExternalOptions
168
169 plugin?: MPlugin
170 }
171 }
172 }