Skip to content

Commit ffbc4b6

Browse files
committed
feat: add regional calls in the functions library
1 parent 1470363 commit ffbc4b6

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/FunctionsClient.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
export class FunctionsClient {
1212
protected url: string
1313
protected headers: Record<string, string>
14+
protected region: string
1415
protected fetch: Fetch
1516

1617
constructor(
@@ -25,6 +26,7 @@ export class FunctionsClient {
2526
) {
2627
this.url = url
2728
this.headers = headers
29+
this.region = 'any'
2830
this.fetch = resolveFetch(customFetch)
2931
}
3032

@@ -47,8 +49,10 @@ export class FunctionsClient {
4749
): Promise<FunctionsResponse<T>> {
4850
try {
4951
const { headers, method, body: functionArgs } = options
50-
5152
let _headers: Record<string, string> = {}
53+
if (this.region !== 'any') {
54+
_headers['x-region'] = this.region
55+
}
5256
let body: any
5357
if (
5458
functionArgs &&

src/types.ts

+18
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,24 @@ export type FunctionInvokeOptions = {
5050
* The HTTP verb of the request
5151
*/
5252
method?: 'POST' | 'GET' | 'PUT' | 'PATCH' | 'DELETE'
53+
/**
54+
* The Region to invoke the function in.
55+
*/
56+
region?: 'any'
57+
| 'ap-northeast-1'
58+
| 'ap-northeast-2'
59+
| 'ap-south-1'
60+
| 'ap-southeast-1'
61+
| 'ap-southeast-2'
62+
| 'ca-central-1'
63+
| 'eu-central-1'
64+
| 'eu-west-1'
65+
| 'eu-west-2'
66+
| 'eu-west-3'
67+
| 'sa-east-1'
68+
| 'us-east-1'
69+
| 'us-west-1'
70+
| 'us-west-2'
5371
/**
5472
* The body of the request.
5573
*/

0 commit comments

Comments
 (0)