diff --git a/types/http-server/http-server-tests.ts b/types/http-server/http-server-tests.ts new file mode 100644 index 0000000000..8e6be14578 --- /dev/null +++ b/types/http-server/http-server-tests.ts @@ -0,0 +1,6 @@ +import { createServer } from "http-server"; + +const server = createServer(); +server.listen(8000); + +server.close(); diff --git a/types/http-server/index.d.ts b/types/http-server/index.d.ts new file mode 100644 index 0000000000..97b4739604 --- /dev/null +++ b/types/http-server/index.d.ts @@ -0,0 +1,30 @@ +// Type definitions for http-server 0.10 +// Project: https://github.com/indexzero/http-server#readme +// Definitions by: York Yao +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as http from "http"; +import * as https from "https"; +import { HandleFunction } from "connect"; + +export function createServer(options?: Options): http.Server | https.Server; + +export interface Options { + root?: string; + headers?: { [name: string]: string }; + cache?: number; + showDir?: boolean | "false"; + autoIndex?: boolean | "false"; + showDotfiles?: boolean; + gzip?: boolean; + contentType?: string; + ext?: boolean; + before?: HandleFunction[]; + // tslint:disable-next-line prefer-method-signature + logFn?: (req: http.IncomingMessage, res: http.ServerResponse, err: Error) => void; + cors?: boolean; + corsHeaders?: string; + robots?: string | true; + proxy?: string; + https?: https.ServerOptions; +} diff --git a/types/http-server/tsconfig.json b/types/http-server/tsconfig.json new file mode 100644 index 0000000000..98f006389c --- /dev/null +++ b/types/http-server/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": [ + "index.d.ts", + "http-server-tests.ts" + ] +} diff --git a/types/http-server/tslint.json b/types/http-server/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/http-server/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }