File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 10
10
* governing permissions and limitations under the License.
11
11
*/
12
12
13
- import { errorWithResponse } from './util.js' ;
13
+ import { errorWithResponse , ffetch } from './util.js' ;
14
+
15
+ /** @type {'CONFIG_SERVICE' | 'STORAGE' } */
16
+ const SOURCE = 'CONFIG_SERVICE' ;
14
17
15
18
/**
16
19
* @param {string[] } patterns - An array of pattern strings to match against.
@@ -47,7 +50,18 @@ export async function resolveConfig(ctx, overrides = {}) {
47
50
/**
48
51
* @type {ConfigMap }
49
52
*/
50
- const confMap = await ctx . env . CONFIGS . get ( siteKey , 'json' ) ;
53
+ let confMap ;
54
+ if ( SOURCE === 'STORAGE' ) {
55
+ confMap = await ctx . storage . get ( siteKey , 'json' ) ;
56
+ } else {
57
+ const res = await ffetch ( `https://main--${ site } --${ org } .aem.page/config.json` ) ;
58
+ if ( res . status === 404 ) {
59
+ throw errorWithResponse ( 404 , 'config not found' ) ;
60
+ }
61
+ const json = await res . json ( ) ;
62
+ confMap = json . public ?. mixerConfig ;
63
+ }
64
+
51
65
if ( ! confMap ) {
52
66
return null ;
53
67
}
Original file line number Diff line number Diff line change 12
12
13
13
/**
14
14
* @param {string } url - The URL to fetch.
15
- * @param {import("@cloudflare/workers-types").RequestInit } init - The request init.
15
+ * @param {import("@cloudflare/workers-types").RequestInit } [ init] - The request init.
16
16
* @returns {Promise<Response> } - A promise that resolves to the response.
17
17
*/
18
18
export async function ffetch ( url , init ) {
You can’t perform that action at this time.
0 commit comments