X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftypings%2Fexpress%2Findex.d.ts;h=1a99b598aabacb6be95983d07e610c81ff5a726c;hb=597f771f3f2bfe4b1e7234a5760e23f0283e2b29;hp=7595e6d86c22ceaafd3bef731f3fd74e1dcc7788;hpb=d95d15598847c7f020aa056e7e6e0c02d2bbf732;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/typings/express/index.d.ts b/server/typings/express/index.d.ts index 7595e6d86..1a99b598a 100644 --- a/server/typings/express/index.d.ts +++ b/server/typings/express/index.d.ts @@ -1,12 +1,20 @@ + +import { OutgoingHttpHeaders } from 'http' import { RegisterServerAuthExternalOptions } from '@server/types' import { - MAbuse, + MAbuseMessage, + MAbuseReporter, MAccountBlocklist, + MActorFollowActorsDefault, MActorUrl, + MChannelBannerAccountDefault, MStreamingPlaylist, MVideoChangeOwnershipFull, MVideoFile, + MVideoFormattableDetails, + MVideoId, MVideoImmutable, + MVideoLive, MVideoPlaylistFull, MVideoPlaylistFullSummary } from '@server/types/models' @@ -15,73 +23,120 @@ import { MPlugin, MServer, MServerBlocklist } from '@server/types/models/server' import { MVideoImportDefault } from '@server/types/models/video/video-import' import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/types/models/video/video-playlist-element' import { MAccountVideoRateAccountVideo } from '@server/types/models/video/video-rate' -import { UserRole } from '@shared/models' +import { HttpMethod, PeerTubeProblemDocumentData, ServerErrorCode, VideoCreate } from '@shared/models' +import { File as UploadXFile, Metadata } from '@uploadx/core' import { RegisteredPlugin } from '../../lib/plugins/plugin-manager' import { MAccountDefault, MActorAccountChannelId, - MActorFollowActorsDefault, MActorFollowActorsDefaultSubscription, MActorFull, - MChannelAccountDefault, MComment, MCommentOwnerVideoReply, MUserDefault, MVideoBlacklist, MVideoCaptionVideo, MVideoFullLight, - MVideoIdThumbnail, MVideoRedundancyVideo, MVideoShareActor, - MVideoThumbnail, - MVideoWithRights + MVideoThumbnail } from '../../types/models' +import { Writable } from 'stream' declare module 'express' { export interface Request { query: any + method: HttpMethod + } + + // Upload using multer or uploadx middleware + export type MulterOrUploadXFile = UploadXFile | Express.Multer.File + + export type UploadFiles = { + [fieldname: string]: MulterOrUploadXFile[] + } | MulterOrUploadXFile[] + + // Partial object used by some functions to check the file mimetype/extension + export type UploadFileForCheck = { + originalname: string + mimetype: string + } + + export type UploadFilesForCheck = { + [fieldname: string]: UploadFileForCheck[] + } | UploadFileForCheck[] + + // Upload file with a duration added by our middleware + export type VideoUploadFile = Pick & { + duration: number } + // Extends Metadata property of UploadX object + export type UploadXFileMetadata = Metadata & VideoCreate & { + previewfile: Express.Multer.File[] + thumbnailfile: Express.Multer.File[] + } + + // Our custom UploadXFile object using our custom metadata + export type CustomUploadXFile = UploadXFile & { metadata: T } + + export type EnhancedUploadXFile = CustomUploadXFile & { + duration: number + path: string + filename: string + } + + // Extends Response with added functions and potential variables passed by middlewares interface Response { + fail: (options: { + message: string + + title?: string + status?: number + type?: ServerErrorCode + instance?: string + + data?: PeerTubeProblemDocumentData + }) => void locals: { - bypassLogin?: { - bypass: boolean - pluginName: string - authName?: string - user: { - username: string - email: string - displayName: string - role: UserRole - } + apicache: { + content: string | Buffer + write: Writable['write'] + writeHead: Response['writeHead'] + end: Response['end'] + cacheable: boolean + headers: OutgoingHttpHeaders } - refreshTokenAuthName?: string - - explicitLogout: boolean + docUrl?: string + videoAPI?: MVideoFormattableDetails videoAll?: MVideoFullLight onlyImmutableVideo?: MVideoImmutable onlyVideo?: MVideoThumbnail - onlyVideoWithRights?: MVideoWithRights - videoId?: MVideoIdThumbnail + videoId?: MVideoId + + videoLive?: MVideoLive videoShare?: MVideoShareActor videoFile?: MVideoFile + videoFileResumable?: EnhancedUploadXFile + videoImport?: MVideoImportDefault videoBlacklist?: MVideoBlacklist videoCaption?: MVideoCaptionVideo - abuse?: MAbuse + abuse?: MAbuseReporter + abuseMessage?: MAbuseMessage videoStreamingPlaylist?: MStreamingPlaylist - videoChannel?: MChannelAccountDefault + videoChannel?: MChannelBannerAccountDefault videoPlaylistFull?: MVideoPlaylistFull videoPlaylistSummary?: MVideoPlaylistFullSummary