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