From f4e64e383af2ca01ed925e18bd4bd71e79470602 Mon Sep 17 00:00:00 2001 From: Hiroshi Ioka Date: Sat, 24 Nov 2018 14:43:57 +0900 Subject: [PATCH] @types/async-busboy: add new package --- types/async-busboy/async-busboy-tests.ts | 16 ++++++++++++++ types/async-busboy/index.d.ts | 28 ++++++++++++++++++++++++ types/async-busboy/tsconfig.json | 23 +++++++++++++++++++ types/async-busboy/tslint.json | 1 + 4 files changed, 68 insertions(+) create mode 100644 types/async-busboy/async-busboy-tests.ts create mode 100644 types/async-busboy/index.d.ts create mode 100644 types/async-busboy/tsconfig.json create mode 100644 types/async-busboy/tslint.json diff --git a/types/async-busboy/async-busboy-tests.ts b/types/async-busboy/async-busboy-tests.ts new file mode 100644 index 0000000000..ee81ca8a8c --- /dev/null +++ b/types/async-busboy/async-busboy-tests.ts @@ -0,0 +1,16 @@ +import Koa = require('koa'); +import asyncBusboy = require('async-busboy'); + +async function middleware(ctx: Koa.Context, next: () => Promise) { + const {files, fields} = await asyncBusboy(ctx.req); +} + +async function middleware2(ctx: Koa.Context, next: () => Promise) { + const {fields} = await asyncBusboy(ctx.req, { + limits: { + fileSize: 2 * 1024 * 1024, + }, + onFile: (fieldname: string, file: NodeJS.ReadableStream, filename: string, encoding: string, mimetype: string) => { + } + }); +} diff --git a/types/async-busboy/index.d.ts b/types/async-busboy/index.d.ts new file mode 100644 index 0000000000..ed92d2717a --- /dev/null +++ b/types/async-busboy/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for async-busboy 0.7 +// Project: https://github.com/m4nuC/async-busboy#readme +// Definitions by: Hiroshi Ioka +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import * as fs from 'fs'; +import * as http from 'http'; + +import busboy = require('busboy'); + +interface Options extends busboy.BusboyConfig { + onFile: ( + fieldname: string, + file: NodeJS.ReadableStream, + filename: string, + encoding: string, + mimetype: string) => void; +} + +type AsyncBusboy = ( + req: http.IncomingMessage, + options?: Options +) => Promise<{fields: {[key: string]: any}; files?: fs.ReadStream[]}>; + +declare const asyncBusboy: AsyncBusboy; + +export = asyncBusboy; diff --git a/types/async-busboy/tsconfig.json b/types/async-busboy/tsconfig.json new file mode 100644 index 0000000000..6dbcd063c5 --- /dev/null +++ b/types/async-busboy/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "async-busboy-tests.ts" + ] +} diff --git a/types/async-busboy/tslint.json b/types/async-busboy/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/async-busboy/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }