@types/async-busboy: add new package

This commit is contained in:
Hiroshi Ioka 2018-11-24 14:43:57 +09:00
parent ffdeb117ad
commit f4e64e383a
4 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,16 @@
import Koa = require('koa');
import asyncBusboy = require('async-busboy');
async function middleware(ctx: Koa.Context, next: () => Promise<any>) {
const {files, fields} = await asyncBusboy(ctx.req);
}
async function middleware2(ctx: Koa.Context, next: () => Promise<any>) {
const {fields} = await asyncBusboy(ctx.req, {
limits: {
fileSize: 2 * 1024 * 1024,
},
onFile: (fieldname: string, file: NodeJS.ReadableStream, filename: string, encoding: string, mimetype: string) => {
}
});
}

28
types/async-busboy/index.d.ts vendored Normal file
View File

@ -0,0 +1,28 @@
// Type definitions for async-busboy 0.7
// Project: https://github.com/m4nuC/async-busboy#readme
// Definitions by: Hiroshi Ioka <https://github.com/hirochachacha>
// 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;

View File

@ -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"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }