From f832cffd77152eebb9b18868afa049c3ac4954e2 Mon Sep 17 00:00:00 2001 From: Mike Marcacci Date: Mon, 13 May 2019 10:46:51 -0700 Subject: [PATCH] Add graphql-upload (#35276) --- types/graphql-upload/graphql-upload-tests.ts | 11 ++++++ types/graphql-upload/index.d.ts | 40 ++++++++++++++++++++ types/graphql-upload/tsconfig.json | 24 ++++++++++++ types/graphql-upload/tslint.json | 1 + 4 files changed, 76 insertions(+) create mode 100644 types/graphql-upload/graphql-upload-tests.ts create mode 100644 types/graphql-upload/index.d.ts create mode 100644 types/graphql-upload/tsconfig.json create mode 100644 types/graphql-upload/tslint.json diff --git a/types/graphql-upload/graphql-upload-tests.ts b/types/graphql-upload/graphql-upload-tests.ts new file mode 100644 index 0000000000..8a83771f2f --- /dev/null +++ b/types/graphql-upload/graphql-upload-tests.ts @@ -0,0 +1,11 @@ +import express from "express"; +import Koa from "koa"; +import { graphqlUploadExpress, graphqlUploadKoa } from "graphql-upload"; + +express() + .use(graphqlUploadExpress({ maxFileSize: 10000000, maxFiles: 10 })) + .listen(3000); + +new Koa() + .use(graphqlUploadKoa({ maxFileSize: 10000000, maxFiles: 10 })) + .listen(3000); diff --git a/types/graphql-upload/index.d.ts b/types/graphql-upload/index.d.ts new file mode 100644 index 0000000000..81ac7bae57 --- /dev/null +++ b/types/graphql-upload/index.d.ts @@ -0,0 +1,40 @@ +// Type definitions for graphql-upload 8.0 +// Project: https://github.com/jaydenseric/graphql-upload#readme +// Definitions by: Mike Marcacci +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.3 + +/* tslint:disable:no-unnecessary-generics */ + +import { IncomingMessage, ServerResponse } from "http"; +import { GraphQLScalarType } from "graphql"; +import { RequestHandler } from "express"; +import { Middleware } from "koa"; + +export interface UploadOptions { + maxFieldSize?: number; + maxFileSize?: number; + maxFiles?: number; +} + +export interface GraphQLOperation { + query: string; + operationName?: null | string; + variables?: null | unknown; +} + +export function processRequest( + request: IncomingMessage, + response: ServerResponse, + uploadOptions?: UploadOptions +): Promise; + +export function graphqlUploadExpress( + uploadOptions?: UploadOptions +): RequestHandler; + +export function graphqlUploadKoa ( + uploadOptions?: UploadOptions +): Middleware; + +export const GraphQLUpload: GraphQLScalarType; diff --git a/types/graphql-upload/tsconfig.json b/types/graphql-upload/tsconfig.json new file mode 100644 index 0000000000..fd905b9253 --- /dev/null +++ b/types/graphql-upload/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true + }, + "files": [ + "index.d.ts", + "graphql-upload-tests.ts" + ] +} diff --git a/types/graphql-upload/tslint.json b/types/graphql-upload/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/graphql-upload/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }