-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
response.ts
43 lines (35 loc) · 938 Bytes
/
response.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
export interface Headers {
location?: string;
[key: string]: any;
}
export interface Options {
headers?: Headers;
body?: { [key: string]: any };
query?: { [key: string]: any };
[key: string]: any;
}
export interface ResponseInterface {
status: number;
headers: { [key: string]: any };
body: { [key: string]: any };
get(field: string): string;
set(field: string, value: string): void;
}
export class OAuthResponse implements ResponseInterface {
status = 200;
body: Record<string, unknown> = {};
headers: Headers = {};
constructor(responseOptions: Options = { headers: {} }) {
this.headers = {
...responseOptions.headers,
};
}
get(field: string): any {
console.log({ headers: this.headers, field });
return "";
// return this.headers[field.toLowerCase()];
}
set(fieldOrHeaders: string, value: any): void {
this.headers[fieldOrHeaders.toLowerCase()] = value;
}
}