@@ -10,6 +10,7 @@ import { getPathInProject } from '../settings.js'
1010interface BaseBlobsContext {
1111 deployID : string
1212 siteID : string
13+ primaryRegion ?: string
1314 token : string
1415}
1516
@@ -27,6 +28,7 @@ export type BlobsContext = BlobsContextWithAPIAccess | BlobsContextWithEdgeAcces
2728let hasPrintedLocalBlobsNotice = false
2829
2930export const BLOBS_CONTEXT_VARIABLE = 'NETLIFY_BLOBS_CONTEXT'
31+ const DEV_REGION = 'dev'
3032
3133const printLocalBlobsNotice = ( ) => {
3234 if ( hasPrintedLocalBlobsNotice ) {
@@ -76,6 +78,7 @@ export const getBlobsContextWithAPIAccess = async ({ debug, projectRoot, siteID
7678 const context : BlobsContextWithAPIAccess = {
7779 apiURL : url ,
7880 deployID : '0' ,
81+ primaryRegion : DEV_REGION ,
7982 siteID,
8083 token,
8184 }
@@ -95,11 +98,23 @@ export const getBlobsContextWithEdgeAccess = async ({ debug, projectRoot, siteID
9598 siteID,
9699 token,
97100 uncachedEdgeURL : url ,
101+ primaryRegion : DEV_REGION ,
98102 }
99103
100104 return context
101105}
102106
107+ /**
108+ * Returns the Blobs metadata that should be added to the Lambda event when
109+ * invoking a serverless function.
110+ */
111+ export const getBlobsEventProperty = ( context : BlobsContextWithEdgeAccess ) => ( {
112+ primary_region : context . primaryRegion ,
113+ url : context . edgeURL ,
114+ url_uncached : context . edgeURL ,
115+ token : context . token ,
116+ } )
117+
103118/**
104119 * Returns a Base-64, JSON-encoded representation of the Blobs context. This is
105120 * the format that the `@netlify/blobs` package expects to find the context in.
0 commit comments