forked from aws/aws-sdk-js-v3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresolveEndpointsConfig.ts
More file actions
46 lines (39 loc) · 1.31 KB
/
resolveEndpointsConfig.ts
File metadata and controls
46 lines (39 loc) · 1.31 KB
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
44
45
46
import { Endpoint, Provider, RegionInfoProvider, UrlParser } from "@aws-sdk/types";
import { getEndpointFromRegion } from "./getEndpointFromRegion";
import { normalizeEndpoint } from "./normalizeEndpoint";
export interface EndpointsInputConfig {
/**
* The fully qualified endpoint of the webservice. This is only required when using a custom endpoint (for example, when using a local version of S3).
*/
endpoint?: string | Endpoint | Provider<Endpoint>;
/**
* Whether TLS is enabled for requests.
*/
tls?: boolean;
}
interface PreviouslyResolved {
regionInfoProvider: RegionInfoProvider;
urlParser: UrlParser;
region: Provider<string>;
}
export interface EndpointsResolvedConfig extends Required<EndpointsInputConfig> {
/**
* Resolved value for input {@link EndpointsResolvedConfig.endpoint}
*/
endpoint: Provider<Endpoint>;
/**
* Whether the endpoint is specified by caller.
* @internal
*/
isCustomEndpoint: boolean;
}
export const resolveEndpointsConfig = <T>(
input: T & EndpointsInputConfig & PreviouslyResolved
): T & EndpointsResolvedConfig => ({
...input,
tls: input.tls ?? true,
endpoint: input.endpoint
? normalizeEndpoint({ ...input, endpoint: input.endpoint })
: () => getEndpointFromRegion(input),
isCustomEndpoint: input.endpoint ? true : false,
});