]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/types/express.d.ts
Implement signup approval in server
[github/Chocobozzz/PeerTube.git] / server / types / express.d.ts
CommitLineData
20bafcb6 1import { OutgoingHttpHeaders } from 'http'
67ed6552
C
2import { RegisterServerAuthExternalOptions } from '@server/types'
3import {
edbc9325 4 MAbuseMessage,
668b7f09 5 MAbuseReporter,
67ed6552 6 MAccountBlocklist,
2cb03dc1 7 MActorFollowActorsDefault,
67ed6552 8 MActorUrl,
2cb03dc1 9 MChannelBannerAccountDefault,
2a491182 10 MChannelSyncChannel,
e364e31e 11 MRegistration,
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'
23import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token'
24import { MPlugin, MServer, MServerBlocklist } from '@server/types/models/server'
25import { MVideoImportDefault } from '@server/types/models/video/video-import'
26import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/types/models/video/video-playlist-element'
27import { MAccountVideoRateAccountVideo } from '@server/types/models/video/video-rate'
c0e8b12e 28import { HttpMethod, PeerTubeProblemDocumentData, ServerErrorCode, VideoCreate } from '@shared/models'
f6d6e7f8 29import { File as UploadXFile, Metadata } from '@uploadx/core'
c24aac6b 30import { RegisteredPlugin } from '../../lib/plugins/plugin-manager'
453e83ea
C
31import {
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 46import { Writable } from 'stream'
2e401e85 47import { MVideoSource } from './models/video/video-source'
e030bfb5 48
dae86118 49declare 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
e364e31e 175 userRegistration?: MRegistration
f6d6e7f8 176
177 server?: MServer
178
179 videoRedundancy?: MVideoRedundancyVideo
dae86118 180
f6d6e7f8 181 accountBlock?: MAccountBlocklist
182 serverBlock?: MServerBlocklist
345da516 183
f6d6e7f8 184 oauth?: {
185 token: MOAuthTokenUser
186 }
ad91e700 187
f6d6e7f8 188 signature?: {
189 actor: MActorAccountChannelId
190 }
4a8d113b 191
868314e8
C
192 videoFileToken?: {
193 user: MUserAccountUrl
194 }
195
f6d6e7f8 196 authenticated?: boolean
197
198 registeredPlugin?: RegisteredPlugin
199
200 externalAuth?: RegisterServerAuthExternalOptions
201
202 plugin?: MPlugin
b2111066
C
203
204 localViewerFull?: MLocalVideoViewerWithWatchSections
2a491182 205
f6d6e7f8 206 }
207 }
dae86118 208}