add types of http-server (#20394)

* add types of http-server

* add strictFunctionTypes

* fix lint
This commit is contained in:
York Yao 2017-10-09 17:36:57 -05:00 committed by Wesley Wigham
parent 0a21515501
commit b4b8c2f7d3
4 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,6 @@
import { createServer } from "http-server";
const server = createServer();
server.listen(8000);
server.close();

30
types/http-server/index.d.ts vendored Normal file
View File

@ -0,0 +1,30 @@
// Type definitions for http-server 0.10
// Project: https://github.com/indexzero/http-server#readme
// Definitions by: York Yao <https://github.com/plantain-00>
// 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;
}

View File

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

View File

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