Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TypeScript definitions #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
27 changes: 27 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -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<Express, 'listen' | 'close'> {
url: string | undefined;
port: number | undefined;
sslUrl: string | undefined;
sslPort: number | undefined;
caCert: string;
http: HttpServer;
https: HttpsServer;

listen: () => Promise<void>;
close: () => Promise<void>;
}
}

declare function createTestServer(options: createTestServer.Options): Promise<createTestServer.Server>;

export = createTestServer;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you test the types? https://github.com/SamVerschueren/tsd