From 851aafefab3c3410c853fb2a5456b97167b0ded4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Sat, 3 Aug 2019 12:17:13 +0100 Subject: [PATCH] Add TypeScript definitions --- package.json | 1 + src/index.d.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/index.d.ts diff --git a/package.json b/package.json index b65624f..53dc72d 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "3.0.1", "description": "Creates a minimal Express server for testing", "main": "src/index.js", + "types": "src/index.d.ts", "scripts": { "test": "xo && nyc ava", "coverage": "nyc report --reporter=text-lcov | coveralls" diff --git a/src/index.d.ts b/src/index.d.ts new file mode 100644 index 0000000..cbcbfea --- /dev/null +++ b/src/index.d.ts @@ -0,0 +1,27 @@ +import {Express} from 'express'; +import {Server as HttpServer} from 'http'; +import {Server as HttpsServer} from 'https'; + +declare namespace createTestServer { + interface Options { + bodyParser?: false | object; + certificate?: string | {days?: number, commonName?: string}; + } + + interface Server extends Omit { + url: string | undefined; + port: number | undefined; + sslUrl: string | undefined; + sslPort: number | undefined; + caCert: string; + http: HttpServer; + https: HttpsServer; + + listen: () => Promise; + close: () => Promise; + } +} + +declare function createTestServer(options: createTestServer.Options): Promise; + +export = createTestServer;