diff --git a/types/express-form-data/express-form-data-tests.ts b/types/express-form-data/express-form-data-tests.ts new file mode 100644 index 0000000000..72387faf9c --- /dev/null +++ b/types/express-form-data/express-form-data-tests.ts @@ -0,0 +1,27 @@ +import express = require('express'); +import os = require('os'); +import { + parse, + format, + stream, + union, +} from 'express-form-data'; + +const app = express(); + +const options = { + uploadDir: os.tmpdir(), + autoClean: true, +}; + +app.use(parse(options)); +app.use(format()); +app.use(stream()); +app.use(union()); + +app.all('/', (req, res, next) => { + console.log(req.body); + res.json(req.body); +}); + +app.listen(8080); diff --git a/types/express-form-data/index.d.ts b/types/express-form-data/index.d.ts new file mode 100644 index 0000000000..55fd4459ea --- /dev/null +++ b/types/express-form-data/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for express-form-data 2.0 +// Project: https://github.com/ortexx/express-form-data#readme +// Definitions by: nomnes +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import { NextHandleFunction } from 'connect'; +import { FormOptions } from 'multiparty'; + +export interface FormDataOptions extends FormOptions { + autoClean?: boolean; +} + +export function parse(options?: FormDataOptions): NextHandleFunction; + +export function format(): NextHandleFunction; + +export function stream(): NextHandleFunction; + +export function union(): NextHandleFunction; diff --git a/types/express-form-data/tsconfig.json b/types/express-form-data/tsconfig.json new file mode 100644 index 0000000000..da97f0daf2 --- /dev/null +++ b/types/express-form-data/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "express-form-data-tests.ts" + ] +} diff --git a/types/express-form-data/tslint.json b/types/express-form-data/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/express-form-data/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }