index.d.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Type definitions for graphql-upload 8.0
  2. // Project: https://github.com/jaydenseric/graphql-upload#readme
  3. // Definitions by: Mike Marcacci <https://github.com/mike-marcacci>
  4. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  5. // TypeScript Version: 3.3
  6. /* tslint:disable:no-unnecessary-generics */
  7. import { IncomingMessage, ServerResponse } from 'http'
  8. import { GraphQLScalarType } from 'graphql'
  9. import { RequestHandler } from 'express'
  10. import { Middleware } from 'koa'
  11. import { ReadStream } from 'fs-capacitor'
  12. export interface UploadOptions {
  13. maxFieldSize?: number
  14. maxFileSize?: number
  15. maxFiles?: number
  16. }
  17. export interface GraphQLOperation {
  18. query: string
  19. operationName?: null | string
  20. variables?: null | unknown
  21. }
  22. export function processRequest(
  23. request: IncomingMessage,
  24. response: ServerResponse,
  25. uploadOptions?: UploadOptions
  26. ): Promise<GraphQLOperation | GraphQLOperation[]>
  27. export function graphqlUploadExpress(
  28. uploadOptions?: UploadOptions
  29. ): RequestHandler
  30. export function graphqlUploadKoa<StateT = any, CustomT = {}>(
  31. uploadOptions?: UploadOptions
  32. ): Middleware<StateT, CustomT>
  33. export const GraphQLUpload: GraphQLScalarType
  34. export interface FileUpload {
  35. filename: string
  36. mimetype: string
  37. encoding: string
  38. createReadStream(): ReadStream
  39. }