@vercel/functions 1.5.0 β 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +3 -58
- package/docs/modules/index.md +1 -1
- package/headers.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,60 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
<a href="https://vercel.com">
|
|
3
|
-
<img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96">
|
|
4
|
-
<h3 align="center">Vercel</h3>
|
|
5
|
-
</a>
|
|
6
|
-
<p align="center">Develop. Preview. Ship.</p>
|
|
7
|
-
</p>
|
|
1
|
+
# `@vercel/functions`
|
|
8
2
|
|
|
9
|
-
|
|
3
|
+
Runtime functions to be used with your Vercel Functions.
|
|
10
4
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
### AWS S3 Example
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
import * as s3 from '@aws-sdk/client-s3';
|
|
17
|
-
import { awsCredentialsProvider } from '@vercel/functions/oidc';
|
|
18
|
-
|
|
19
|
-
const s3Client = new s3.S3Client({
|
|
20
|
-
credentials: awsCredentialsProvider({
|
|
21
|
-
roleArn: process.env.AWS_ROLE_ARN,
|
|
22
|
-
}),
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
export const GET = () => {
|
|
26
|
-
const result = await s3Client.send(
|
|
27
|
-
new s3.ListObjectsV2Command({
|
|
28
|
-
Bucket: process.env.BUCKET_NAME,
|
|
29
|
-
})
|
|
30
|
-
);
|
|
31
|
-
return Response.json({ objects: result.Contents });
|
|
32
|
-
};
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### Azure CosmosDB Example
|
|
36
|
-
|
|
37
|
-
```ts
|
|
38
|
-
import { ClientAssertionCredential } from '@azure/identity';
|
|
39
|
-
import { CosmosClient } from '@azure/cosmos';
|
|
40
|
-
import { getVercelOidcToken } from '@vercel/functions/oidc';
|
|
41
|
-
|
|
42
|
-
const credentialsProvider = new ClientAssertionCredential(
|
|
43
|
-
process.env.AZURE_TENANT_ID,
|
|
44
|
-
process.env.AZURE_CLIENT_ID,
|
|
45
|
-
getVercelOidcToken
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
const cosmosClient = new CosmosClient({
|
|
49
|
-
endpoint: process.env.COSMOS_DB_ENDPOINT,
|
|
50
|
-
aadCredentials: credentialsProvider,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
export const GET = () => {
|
|
54
|
-
const container = cosmosClient
|
|
55
|
-
.database(process.env.COSMOS_DB_NAME)
|
|
56
|
-
.container(process.env.COSMOS_DB_CONTAINER);
|
|
57
|
-
const items = await container.items.query('SELECT * FROM f').fetchAll();
|
|
58
|
-
return Response.json({ items: items.resources });
|
|
59
|
-
};
|
|
60
|
-
```
|
|
5
|
+
Please [follow the documentation](https://vercel.com/docs/functions/vercel-functions-package) for examples and usage.
|
package/docs/modules/index.md
CHANGED
package/headers.d.ts
CHANGED
|
@@ -98,7 +98,7 @@ export declare function ipAddress(input: Request | Headers): string | undefined;
|
|
|
98
98
|
* "country": "US",
|
|
99
99
|
* "flag": "πΊπΈ",
|
|
100
100
|
* "countryRegion": "NY",
|
|
101
|
-
* "region": "
|
|
101
|
+
* "region": "iad1",
|
|
102
102
|
* "latitude": "40.7128",
|
|
103
103
|
* "longitude": "-74.0060"
|
|
104
104
|
* }
|