Skip to content

Commit f41eee9

Browse files
authored
Add http types (#10)
* Ensure types package is emitting declarations * Add generic HTTP types
1 parent 01d5b58 commit f41eee9

File tree

5 files changed

+39
-8
lines changed

5 files changed

+39
-8
lines changed

packages/types/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/node_modules/
22
*.js
33
*.js.map
4+
*.d.ts

packages/types/http.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Represents an HTTP message with headers and an optional static or streaming
3+
* body.
4+
*/
5+
export interface HttpMessage<StreamType = Uint8Array> {
6+
headers: {[key: string]: Array<string>};
7+
body?: ArrayBuffer|ArrayBufferView|string|StreamType;
8+
}
9+
10+
/**
11+
* Represents an HTTP message constructed to be sent to a host. Contains
12+
* addressing information in addition to standard message properties.
13+
*/
14+
export interface HttpRequest<StreamType = Uint8Array> extends
15+
HttpMessage<StreamType>
16+
{
17+
method: string;
18+
protocol: string;
19+
hostname: string;
20+
port: number;
21+
path: string;
22+
query?: {[key: string]: string|Array<string>};
23+
}
24+
25+
/**
26+
* Represents an HTTP message as received in reply to a request. Contains a
27+
* numeric status code in addition to standard message properties.
28+
*/
29+
export interface HttpResponse<StreamType = Uint8Array> extends
30+
HttpMessage<StreamType>
31+
{
32+
statusCode: number;
33+
}

packages/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from './credentials';
2+
export * from './http';
23
export * from './protocol';

packages/types/protocol.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface Member {
1818
xmlNamespace?: XmlNamespace;
1919
}
2020

21-
interface Shape {
21+
export interface Shape {
2222
type: SerializationType;
2323
sensitive?: boolean;
2424
}

packages/types/tsconfig.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
{
2-
"compileOnSave": true,
32
"compilerOptions": {
43
"module": "commonjs",
54
"target": "es5",
6-
"alwaysStrict": true,
7-
"strictNullChecks": true,
8-
"noImplicitAny": true,
5+
"strict": true,
96
"sourceMap": true,
10-
"noImplicitThis": true
11-
},
12-
"exclude": ["node_modules"]
7+
"declaration": true
8+
}
139
}

0 commit comments

Comments
 (0)