@ohos-ports/layer0-prefetch 4.20.0-beta.0 → 4.20.0-beta.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/node_modules/@layer0/core/README.md +50 -0
- package/node_modules/@layer0/core/build.d.ts +5 -0
- package/node_modules/@layer0/core/build.js +17 -0
- package/node_modules/@layer0/core/cache/Cache.d.ts +56 -0
- package/node_modules/@layer0/core/cache/Cache.js +138 -0
- package/node_modules/@layer0/core/cache/CacheKey.d.ts +52 -0
- package/node_modules/@layer0/core/cache/CacheKey.js +95 -0
- package/node_modules/@layer0/core/config.d.ts +53 -0
- package/node_modules/@layer0/core/config.js +113 -0
- package/node_modules/@layer0/core/constants.d.ts +214 -0
- package/node_modules/@layer0/core/constants.js +216 -0
- package/node_modules/@layer0/core/context.d.ts +38 -0
- package/node_modules/@layer0/core/context.js +98 -0
- package/node_modules/@layer0/core/default-app/all/layer0.config.js +60 -0
- package/node_modules/@layer0/core/default-app/js/routes.js +27 -0
- package/node_modules/@layer0/core/default-app/ts/routes.ts +27 -0
- package/node_modules/@layer0/core/deploy/DeploymentBuilder.d.ts +177 -0
- package/node_modules/@layer0/core/deploy/DeploymentBuilder.js +543 -0
- package/node_modules/@layer0/core/deploy/bundle-esbuild.d.ts +11 -0
- package/node_modules/@layer0/core/deploy/bundle-esbuild.js +67 -0
- package/node_modules/@layer0/core/deploy/bundle-ncc.d.ts +8 -0
- package/node_modules/@layer0/core/deploy/bundle-ncc.js +30 -0
- package/node_modules/@layer0/core/deploy/bundle-nft.d.ts +7 -0
- package/node_modules/@layer0/core/deploy/bundle-nft.js +41 -0
- package/node_modules/@layer0/core/deploy/bundle-webpack.d.ts +11 -0
- package/node_modules/@layer0/core/deploy/bundle-webpack.js +127 -0
- package/node_modules/@layer0/core/deploy/index.d.ts +19 -0
- package/node_modules/@layer0/core/deploy/index.js +6 -0
- package/node_modules/@layer0/core/deploy/listSources.d.ts +11 -0
- package/node_modules/@layer0/core/deploy/listSources.js +18 -0
- package/node_modules/@layer0/core/deploy/paths.d.ts +27 -0
- package/node_modules/@layer0/core/deploy/paths.js +33 -0
- package/node_modules/@layer0/core/deploy/resolveInPackage.d.ts +7 -0
- package/node_modules/@layer0/core/deploy/resolveInPackage.js +21 -0
- package/node_modules/@layer0/core/deploy/routeToFiles.d.ts +14 -0
- package/node_modules/@layer0/core/deploy/routeToFiles.js +24 -0
- package/node_modules/@layer0/core/dev/DevServerOptions.d.ts +33 -0
- package/node_modules/@layer0/core/dev/DevServerOptions.js +2 -0
- package/node_modules/@layer0/core/dev/createDevServer.d.ts +8 -0
- package/node_modules/@layer0/core/dev/createDevServer.js +114 -0
- package/node_modules/@layer0/core/dev/index.d.ts +3 -0
- package/node_modules/@layer0/core/dev/index.js +6 -0
- package/node_modules/@layer0/core/dev/runLocalApp.d.ts +8 -0
- package/node_modules/@layer0/core/dev/runLocalApp.js +73 -0
- package/node_modules/@layer0/core/dev/serverlessCompatibilityMiddleware.d.ts +11 -0
- package/node_modules/@layer0/core/dev/serverlessCompatibilityMiddleware.js +30 -0
- package/node_modules/@layer0/core/edge/EdgeErrorPageResponseWriter.d.ts +12 -0
- package/node_modules/@layer0/core/edge/EdgeErrorPageResponseWriter.js +22 -0
- package/node_modules/@layer0/core/edge/EdgeResponseWriter.d.ts +122 -0
- package/node_modules/@layer0/core/edge/EdgeResponseWriter.js +451 -0
- package/node_modules/@layer0/core/edge/createEdgeConfig.d.ts +16 -0
- package/node_modules/@layer0/core/edge/createEdgeConfig.js +284 -0
- package/node_modules/@layer0/core/environment.d.ts +24 -0
- package/node_modules/@layer0/core/environment.js +42 -0
- package/node_modules/@layer0/core/errors/BackendFetchError.d.ts +11 -0
- package/node_modules/@layer0/core/errors/BackendFetchError.js +17 -0
- package/node_modules/@layer0/core/errors/FrameworkBuildError.d.ts +7 -0
- package/node_modules/@layer0/core/errors/FrameworkBuildError.js +26 -0
- package/node_modules/@layer0/core/index.d.ts +3 -0
- package/node_modules/@layer0/core/index.js +9 -0
- package/node_modules/@layer0/core/init/addToPackageJson.d.ts +7 -0
- package/node_modules/@layer0/core/init/addToPackageJson.js +22 -0
- package/node_modules/@layer0/core/init/index.d.ts +2 -0
- package/node_modules/@layer0/core/init/index.js +6 -0
- package/node_modules/@layer0/core/init/init.d.ts +5 -0
- package/node_modules/@layer0/core/init/init.js +17 -0
- package/node_modules/@layer0/core/lambda/JSBackend.d.ts +30 -0
- package/node_modules/@layer0/core/lambda/JSBackend.js +51 -0
- package/node_modules/@layer0/core/lambda/RequestListenerJSBackend.d.ts +8 -0
- package/node_modules/@layer0/core/lambda/RequestListenerJSBackend.js +19 -0
- package/node_modules/@layer0/core/lambda/adaptResponseEncodingToDownstream.d.ts +17 -0
- package/node_modules/@layer0/core/lambda/adaptResponseEncodingToDownstream.js +132 -0
- package/node_modules/@layer0/core/lambda/consoleWrapper.d.ts +16 -0
- package/node_modules/@layer0/core/lambda/consoleWrapper.js +127 -0
- package/node_modules/@layer0/core/lambda/getBodyLoggingData.d.ts +10 -0
- package/node_modules/@layer0/core/lambda/getBodyLoggingData.js +108 -0
- package/node_modules/@layer0/core/lambda/handler.d.ts +1 -0
- package/node_modules/@layer0/core/lambda/handler.js +91 -0
- package/node_modules/@layer0/core/lambda/handler.js.map +7 -0
- package/node_modules/@layer0/core/lambda/innerHandler.d.ts +7 -0
- package/node_modules/@layer0/core/lambda/innerHandler.js +181 -0
- package/node_modules/@layer0/core/lambda/lambdaInstance.d.ts +29 -0
- package/node_modules/@layer0/core/lambda/lambdaInstance.js +71 -0
- package/node_modules/@layer0/core/lambda/reqResMapper.d.ts +24 -0
- package/node_modules/@layer0/core/lambda/reqResMapper.js +286 -0
- package/node_modules/@layer0/core/lambda/stdStreamsWrapper.d.ts +31 -0
- package/node_modules/@layer0/core/lambda/stdStreamsWrapper.js +196 -0
- package/node_modules/@layer0/core/lambda/toJSBackend.d.ts +10 -0
- package/node_modules/@layer0/core/lambda/toJSBackend.js +23 -0
- package/node_modules/@layer0/core/node_modules/esbuild/LICENSE.md +21 -0
- package/node_modules/@layer0/core/node_modules/esbuild/README.md +3 -0
- package/node_modules/@layer0/core/node_modules/esbuild/bin/esbuild +223 -0
- package/node_modules/@layer0/core/node_modules/esbuild/install.js +301 -0
- package/node_modules/@layer0/core/node_modules/esbuild/lib/main.d.ts +716 -0
- package/node_modules/@layer0/core/node_modules/esbuild/lib/main.js +2532 -0
- package/node_modules/@layer0/core/node_modules/esbuild/node_modules/@ohos-ports/esbuild-openharmony-arm64/README.md +3 -0
- package/node_modules/@layer0/core/node_modules/esbuild/node_modules/@ohos-ports/esbuild-openharmony-arm64/bin/esbuild +0 -0
- package/node_modules/@layer0/core/node_modules/esbuild/node_modules/@ohos-ports/esbuild-openharmony-arm64/esbuild.wasm +0 -0
- package/node_modules/@layer0/core/node_modules/esbuild/node_modules/@ohos-ports/esbuild-openharmony-arm64/package.json +28 -0
- package/node_modules/@layer0/core/node_modules/esbuild/node_modules/@ohos-ports/esbuild-openharmony-arm64/wasm_exec.js +575 -0
- package/node_modules/@layer0/core/node_modules/esbuild/node_modules/@ohos-ports/esbuild-openharmony-arm64/wasm_exec_node.js +40 -0
- package/node_modules/@layer0/core/node_modules/esbuild/package.json +78 -0
- package/node_modules/@layer0/core/package.json +132 -0
- package/node_modules/@layer0/core/parser/parseRouter.d.ts +13 -0
- package/node_modules/@layer0/core/parser/parseRouter.js +77 -0
- package/node_modules/@layer0/core/plugins/PluginBase.d.ts +18 -0
- package/node_modules/@layer0/core/plugins/PluginBase.js +19 -0
- package/node_modules/@layer0/core/router/Backend.d.ts +69 -0
- package/node_modules/@layer0/core/router/Backend.js +176 -0
- package/node_modules/@layer0/core/router/BackendOptions.d.ts +11 -0
- package/node_modules/@layer0/core/router/BackendOptions.js +2 -0
- package/node_modules/@layer0/core/router/BaseResponseWriter.d.ts +65 -0
- package/node_modules/@layer0/core/router/BaseResponseWriter.js +81 -0
- package/node_modules/@layer0/core/router/BehindEdgeResponseWriterProxy.d.ts +4 -0
- package/node_modules/@layer0/core/router/BehindEdgeResponseWriterProxy.js +89 -0
- package/node_modules/@layer0/core/router/CacheManifest.d.ts +80 -0
- package/node_modules/@layer0/core/router/CacheManifest.js +83 -0
- package/node_modules/@layer0/core/router/CacheOptions.d.ts +171 -0
- package/node_modules/@layer0/core/router/CacheOptions.js +2 -0
- package/node_modules/@layer0/core/router/CustomCacheKey.d.ts +140 -0
- package/node_modules/@layer0/core/router/CustomCacheKey.js +272 -0
- package/node_modules/@layer0/core/router/GroupConfig.d.ts +7 -0
- package/node_modules/@layer0/core/router/GroupConfig.js +20 -0
- package/node_modules/@layer0/core/router/Groups.d.ts +7 -0
- package/node_modules/@layer0/core/router/Groups.js +21 -0
- package/node_modules/@layer0/core/router/Headers.d.ts +3 -0
- package/node_modules/@layer0/core/router/Headers.js +2 -0
- package/node_modules/@layer0/core/router/PathMatcher.d.ts +51 -0
- package/node_modules/@layer0/core/router/PathMatcher.js +73 -0
- package/node_modules/@layer0/core/router/Preload.d.ts +16 -0
- package/node_modules/@layer0/core/router/Preload.js +2 -0
- package/node_modules/@layer0/core/router/PreloadRequests.d.ts +23 -0
- package/node_modules/@layer0/core/router/PreloadRequests.js +66 -0
- package/node_modules/@layer0/core/router/Request.d.ts +74 -0
- package/node_modules/@layer0/core/router/Request.js +2 -0
- package/node_modules/@layer0/core/router/RequestContext.d.ts +12 -0
- package/node_modules/@layer0/core/router/RequestContext.js +11 -0
- package/node_modules/@layer0/core/router/Response.d.ts +55 -0
- package/node_modules/@layer0/core/router/Response.js +2 -0
- package/node_modules/@layer0/core/router/ResponseWriter.d.ts +1011 -0
- package/node_modules/@layer0/core/router/ResponseWriter.js +1341 -0
- package/node_modules/@layer0/core/router/Route.d.ts +124 -0
- package/node_modules/@layer0/core/router/Route.js +280 -0
- package/node_modules/@layer0/core/router/RouteCriteria.d.ts +68 -0
- package/node_modules/@layer0/core/router/RouteCriteria.js +2 -0
- package/node_modules/@layer0/core/router/RouteGroup.d.ts +157 -0
- package/node_modules/@layer0/core/router/RouteGroup.js +223 -0
- package/node_modules/@layer0/core/router/RouteGroupList.d.ts +45 -0
- package/node_modules/@layer0/core/router/RouteGroupList.js +73 -0
- package/node_modules/@layer0/core/router/Router.d.ts +439 -0
- package/node_modules/@layer0/core/router/Router.js +907 -0
- package/node_modules/@layer0/core/router/addBuiltInRoutes.d.ts +2 -0
- package/node_modules/@layer0/core/router/addBuiltInRoutes.js +58 -0
- package/node_modules/@layer0/core/router/addPreloadHeaders.d.ts +7 -0
- package/node_modules/@layer0/core/router/addPreloadHeaders.js +57 -0
- package/node_modules/@layer0/core/router/cacheManifestFromRouter.d.ts +6 -0
- package/node_modules/@layer0/core/router/cacheManifestFromRouter.js +85 -0
- package/node_modules/@layer0/core/router/createCustomCacheKey.d.ts +27 -0
- package/node_modules/@layer0/core/router/createCustomCacheKey.js +35 -0
- package/node_modules/@layer0/core/router/deriveSurrogateKeysFromJson.d.ts +36 -0
- package/node_modules/@layer0/core/router/deriveSurrogateKeysFromJson.js +70 -0
- package/node_modules/@layer0/core/router/index.d.ts +11 -0
- package/node_modules/@layer0/core/router/index.js +17 -0
- package/node_modules/@layer0/core/router/interpolateParams.d.ts +21 -0
- package/node_modules/@layer0/core/router/interpolateParams.js +150 -0
- package/node_modules/@layer0/core/router/loadRouter.d.ts +13 -0
- package/node_modules/@layer0/core/router/loadRouter.js +29 -0
- package/node_modules/@layer0/core/router/mergeQueryString.d.ts +1 -0
- package/node_modules/@layer0/core/router/mergeQueryString.js +23 -0
- package/node_modules/@layer0/core/router/normalizeCriteria.d.ts +6 -0
- package/node_modules/@layer0/core/router/normalizeCriteria.js +20 -0
- package/node_modules/@layer0/core/router/stream.d.ts +12 -0
- package/node_modules/@layer0/core/router/stream.js +30 -0
- package/node_modules/@layer0/core/router/universalRouteUtils.d.ts +55 -0
- package/node_modules/@layer0/core/router/universalRouteUtils.js +114 -0
- package/node_modules/@layer0/core/router/validateWriter.d.ts +41 -0
- package/node_modules/@layer0/core/router/validateWriter.js +120 -0
- package/node_modules/@layer0/core/serverless.yml +30 -0
- package/node_modules/@layer0/core/source.d.ts +9 -0
- package/node_modules/@layer0/core/source.js +17 -0
- package/node_modules/@layer0/core/test-utils/MockRequest.d.ts +15 -0
- package/node_modules/@layer0/core/test-utils/MockRequest.js +36 -0
- package/node_modules/@layer0/core/test-utils/MockResponse.d.ts +7 -0
- package/node_modules/@layer0/core/test-utils/MockResponse.js +24 -0
- package/node_modules/@layer0/core/test-utils/expect-extend.d.ts +1 -0
- package/node_modules/@layer0/core/test-utils/expect-extend.js +11 -0
- package/node_modules/@layer0/core/test-utils/index.d.ts +4 -0
- package/node_modules/@layer0/core/test-utils/index.js +11 -0
- package/node_modules/@layer0/core/test-utils/matchers/toBeCachedByTheBrowser.d.ts +19 -0
- package/node_modules/@layer0/core/test-utils/matchers/toBeCachedByTheBrowser.js +45 -0
- package/node_modules/@layer0/core/test-utils/matchers/toBeCachedByTheEdge.d.ts +19 -0
- package/node_modules/@layer0/core/test-utils/matchers/toBeCachedByTheEdge.js +38 -0
- package/node_modules/@layer0/core/test-utils/matchers/toBeCachedByTheServiceWorker.d.ts +19 -0
- package/node_modules/@layer0/core/test-utils/matchers/toBeCachedByTheServiceWorker.js +45 -0
- package/node_modules/@layer0/core/test-utils/matchers/toBeServedStale.d.ts +20 -0
- package/node_modules/@layer0/core/test-utils/matchers/toBeServedStale.js +50 -0
- package/node_modules/@layer0/core/test-utils/matchers/toHaveBody.d.ts +18 -0
- package/node_modules/@layer0/core/test-utils/matchers/toHaveBody.js +40 -0
- package/node_modules/@layer0/core/test-utils/matchers/toHaveHeader.d.ts +19 -0
- package/node_modules/@layer0/core/test-utils/matchers/toHaveHeader.js +43 -0
- package/node_modules/@layer0/core/test-utils/matchers.d.ts +6 -0
- package/node_modules/@layer0/core/test-utils/matchers.js +18 -0
- package/node_modules/@layer0/core/test-utils/utils/createRouteMock.d.ts +21 -0
- package/node_modules/@layer0/core/test-utils/utils/createRouteMock.js +27 -0
- package/node_modules/@layer0/core/test-utils/utils/getBackend.d.ts +13 -0
- package/node_modules/@layer0/core/test-utils/utils/getBackend.js +30 -0
- package/node_modules/@layer0/core/test-utils/utils/getMessage.d.ts +1 -0
- package/node_modules/@layer0/core/test-utils/utils/getMessage.js +16 -0
- package/node_modules/@layer0/core/test-utils/utils/runRoute.d.ts +10 -0
- package/node_modules/@layer0/core/test-utils/utils/runRoute.js +39 -0
- package/node_modules/@layer0/core/timing.d.ts +115 -0
- package/node_modules/@layer0/core/timing.js +200 -0
- package/node_modules/@layer0/core/transform/index.d.ts +1 -0
- package/node_modules/@layer0/core/transform/index.js +4 -0
- package/node_modules/@layer0/core/transform/transformMethod.d.ts +40 -0
- package/node_modules/@layer0/core/transform/transformMethod.js +58 -0
- package/node_modules/@layer0/core/types.d.ts +102 -0
- package/node_modules/@layer0/core/types.js +30 -0
- package/node_modules/@layer0/core/utils/Tasks.d.ts +32 -0
- package/node_modules/@layer0/core/utils/Tasks.js +80 -0
- package/node_modules/@layer0/core/utils/Validator.d.ts +18 -0
- package/node_modules/@layer0/core/utils/Validator.js +178 -0
- package/node_modules/@layer0/core/utils/bindParamsToPath.d.ts +15 -0
- package/node_modules/@layer0/core/utils/bindParamsToPath.js +49 -0
- package/node_modules/@layer0/core/utils/convertParamsToBackReferences.d.ts +16 -0
- package/node_modules/@layer0/core/utils/convertParamsToBackReferences.js +45 -0
- package/node_modules/@layer0/core/utils/convertStringMatcherToRegex.d.ts +7 -0
- package/node_modules/@layer0/core/utils/convertStringMatcherToRegex.js +26 -0
- package/node_modules/@layer0/core/utils/decode.d.ts +9 -0
- package/node_modules/@layer0/core/utils/decode.js +44 -0
- package/node_modules/@layer0/core/utils/esImport.d.ts +1 -0
- package/node_modules/@layer0/core/utils/esImport.js +9 -0
- package/node_modules/@layer0/core/utils/fs.d.ts +1 -0
- package/node_modules/@layer0/core/utils/fs.js +7 -0
- package/node_modules/@layer0/core/utils/get.d.ts +6 -0
- package/node_modules/@layer0/core/utils/get.js +19 -0
- package/node_modules/@layer0/core/utils/getPackageVersion.d.ts +7 -0
- package/node_modules/@layer0/core/utils/getPackageVersion.js +19 -0
- package/node_modules/@layer0/core/utils/has.d.ts +6 -0
- package/node_modules/@layer0/core/utils/has.js +15 -0
- package/node_modules/@layer0/core/utils/identity.d.ts +7 -0
- package/node_modules/@layer0/core/utils/identity.js +12 -0
- package/node_modules/@layer0/core/utils/index.d.ts +1 -0
- package/node_modules/@layer0/core/utils/index.js +4 -0
- package/node_modules/@layer0/core/utils/isEmpty.d.ts +6 -0
- package/node_modules/@layer0/core/utils/isEmpty.js +20 -0
- package/node_modules/@layer0/core/utils/isString.d.ts +1 -0
- package/node_modules/@layer0/core/utils/isString.js +6 -0
- package/node_modules/@layer0/core/utils/logo.d.ts +5 -0
- package/node_modules/@layer0/core/utils/logo.js +27 -0
- package/node_modules/@layer0/core/utils/mapValues.d.ts +7 -0
- package/node_modules/@layer0/core/utils/mapValues.js +16 -0
- package/node_modules/@layer0/core/utils/minBy.d.ts +8 -0
- package/node_modules/@layer0/core/utils/minBy.js +41 -0
- package/node_modules/@layer0/core/utils/nonWebpackRequire.d.ts +11 -0
- package/node_modules/@layer0/core/utils/nonWebpackRequire.js +28 -0
- package/node_modules/@layer0/core/utils/packageUtils.d.ts +12 -0
- package/node_modules/@layer0/core/utils/packageUtils.js +22 -0
- package/node_modules/@layer0/core/utils/ports.d.ts +5 -0
- package/node_modules/@layer0/core/utils/ports.js +7 -0
- package/node_modules/@layer0/core/utils/readBody.d.ts +7 -0
- package/node_modules/@layer0/core/utils/readBody.js +15 -0
- package/node_modules/@layer0/core/utils/readRawBody.d.ts +9 -0
- package/node_modules/@layer0/core/utils/readRawBody.js +21 -0
- package/node_modules/@layer0/core/utils/regExpEscape.d.ts +12 -0
- package/node_modules/@layer0/core/utils/regExpEscape.js +20 -0
- package/node_modules/@layer0/core/utils/requireInternal.d.ts +7 -0
- package/node_modules/@layer0/core/utils/requireInternal.js +24 -0
- package/node_modules/@layer0/core/utils/set.d.ts +10 -0
- package/node_modules/@layer0/core/utils/set.js +21 -0
- package/node_modules/@layer0/core/utils/toEdgeRegex.d.ts +11 -0
- package/node_modules/@layer0/core/utils/toEdgeRegex.js +23 -0
- package/node_modules/@layer0/core/utils/toHttpMethodMatchRegex.d.ts +12 -0
- package/node_modules/@layer0/core/utils/toHttpMethodMatchRegex.js +17 -0
- package/node_modules/@layer0/core/utils/toLower.d.ts +1 -0
- package/node_modules/@layer0/core/utils/toLower.js +9 -0
- package/node_modules/@layer0/core/utils/validateBackends.d.ts +5 -0
- package/node_modules/@layer0/core/utils/validateBackends.js +30 -0
- package/node_modules/@layer0/core/utils/watch.d.ts +10 -0
- package/node_modules/@layer0/core/utils/watch.js +17 -0
- package/package.json +47 -3
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layer0 configuration file name.
|
|
3
|
+
*/
|
|
4
|
+
export declare const LAYER0_CONFIG_FILE = "layer0.config.js";
|
|
5
|
+
/**
|
|
6
|
+
* Indicate asset files that need to be uploaded under a different
|
|
7
|
+
* bucket key.
|
|
8
|
+
* It contains values like
|
|
9
|
+
* {
|
|
10
|
+
* '/posts' => '/posts/index.html'
|
|
11
|
+
* }
|
|
12
|
+
*/
|
|
13
|
+
export declare const LAYER0_ASSET_ALIASES_FILE = "asset-aliases.json";
|
|
14
|
+
/**
|
|
15
|
+
* Environment variables used by Layer0.
|
|
16
|
+
*/
|
|
17
|
+
export declare const LAYER0_ENV_VARIABLES: {
|
|
18
|
+
/**
|
|
19
|
+
* Layer0 configuration environment variable key.
|
|
20
|
+
*/
|
|
21
|
+
config: string;
|
|
22
|
+
/**
|
|
23
|
+
* Indicates whether code is running locally or in the cloud.
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
deploymentType: string;
|
|
27
|
+
/**
|
|
28
|
+
* Allows Layer0 development team to easily override Layer0 version
|
|
29
|
+
* during development process.
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
versionOverride: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Indicates that code is running in AWS.
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
export declare const LAYER0_DEPLOYMENT_TYPE_AWS = "AWS";
|
|
39
|
+
/**
|
|
40
|
+
* Prefix of all Layer0 headers.
|
|
41
|
+
*/
|
|
42
|
+
export declare const LAYER0_HEADERS_PREFIX = "x-0-";
|
|
43
|
+
/**
|
|
44
|
+
* Maximum number of user headers allowed by Layer0 platform.
|
|
45
|
+
*
|
|
46
|
+
* We limit the request and response headers allowed to 70. This is due to a limitation that edge has
|
|
47
|
+
* which at the moment supports up to 96 headers. Edge provider itself needs to use some of those headers
|
|
48
|
+
* with the remainder used by our edge code.
|
|
49
|
+
*
|
|
50
|
+
* NOTE: This constant must be equal ot the constant of the same name defined in Layer0 buffer proxy.
|
|
51
|
+
* NOTE: If this constant is updated then the constant of the same name has to be updated in @layer0/build-lambda module.
|
|
52
|
+
*/
|
|
53
|
+
export declare const LAYER0_MAX_USER_HEADERS_ALLOWED = 70;
|
|
54
|
+
/**
|
|
55
|
+
* Status code returned when there are too many request or response headers.
|
|
56
|
+
*
|
|
57
|
+
* Must be equal to HeaderOverflowError status code as defined in build lambda and Layer0 buffer proxy.
|
|
58
|
+
*/
|
|
59
|
+
export declare const LAYER0_TOO_MANY_HEADERS_STATUS_CODE = 542;
|
|
60
|
+
/**
|
|
61
|
+
* The status code returned when the layer0_prefetch query param is present and a response could not be found in the cache.
|
|
62
|
+
*/
|
|
63
|
+
export declare const LAYER0_UNCACHED_PREFETCH_STATUS = 412;
|
|
64
|
+
/**
|
|
65
|
+
* CDN-as-code configuration actions
|
|
66
|
+
*/
|
|
67
|
+
export declare const ACTIONS: {
|
|
68
|
+
setHeader: string;
|
|
69
|
+
updateHeader: string;
|
|
70
|
+
removeHeader: string;
|
|
71
|
+
syntheticRes: string;
|
|
72
|
+
updatePath: string;
|
|
73
|
+
proxy: string;
|
|
74
|
+
addCookie: string;
|
|
75
|
+
updateCookie: string;
|
|
76
|
+
removeCookie: string;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* The backend for cloud functions
|
|
80
|
+
*/
|
|
81
|
+
export declare const BACKENDS: {
|
|
82
|
+
js: string;
|
|
83
|
+
static: string;
|
|
84
|
+
permanentStatic: string;
|
|
85
|
+
imageOptimizer: string;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* The hostname used for the internal service running the user's application.
|
|
89
|
+
*/
|
|
90
|
+
export declare const JS_BACKEND_HOSTNAME = "127.0.0.1";
|
|
91
|
+
export declare const HTTP_METHODS: {
|
|
92
|
+
head: string;
|
|
93
|
+
get: string;
|
|
94
|
+
post: string;
|
|
95
|
+
delete: string;
|
|
96
|
+
put: string;
|
|
97
|
+
patch: string;
|
|
98
|
+
options: string;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Common HTTP headers.
|
|
102
|
+
*/
|
|
103
|
+
export declare const HTTP_HEADERS: {
|
|
104
|
+
acceptEncoding: string;
|
|
105
|
+
authorization: string;
|
|
106
|
+
cacheControl: string;
|
|
107
|
+
contentEncoding: string;
|
|
108
|
+
contentLength: string;
|
|
109
|
+
contentType: string;
|
|
110
|
+
cookie: string;
|
|
111
|
+
host: string;
|
|
112
|
+
location: string;
|
|
113
|
+
serverTiming: string;
|
|
114
|
+
setCookie: string;
|
|
115
|
+
userAgent: string;
|
|
116
|
+
vary: string;
|
|
117
|
+
via: string;
|
|
118
|
+
x0Browser: string;
|
|
119
|
+
x0CacheControl: string;
|
|
120
|
+
x0CacheVersion: string;
|
|
121
|
+
x0CachingStatus: string;
|
|
122
|
+
x0ClientIp: string;
|
|
123
|
+
x0Components: string;
|
|
124
|
+
x0Destination: string;
|
|
125
|
+
x0Device: string;
|
|
126
|
+
x0DeviceIsBot: string;
|
|
127
|
+
x0GeoCity: string;
|
|
128
|
+
x0GeoCountryCode: string;
|
|
129
|
+
x0GeoLatitude: string;
|
|
130
|
+
x0GeoLongitude: string;
|
|
131
|
+
x0GeoPostalCode: string;
|
|
132
|
+
x0MatchedRoutes: string;
|
|
133
|
+
x0Protocol: string;
|
|
134
|
+
x0Route: string;
|
|
135
|
+
x0Status: string;
|
|
136
|
+
x0SurrogateKey: string;
|
|
137
|
+
x0T: string;
|
|
138
|
+
x0UserT: string;
|
|
139
|
+
x0Vendor: string;
|
|
140
|
+
x0Version: string;
|
|
141
|
+
xForwardedFor: string;
|
|
142
|
+
xRequestId: string;
|
|
143
|
+
xSwCacheControl: string;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Values for x-0-caching-status
|
|
147
|
+
*/
|
|
148
|
+
export declare const CACHING_STATUS: {
|
|
149
|
+
ok: string;
|
|
150
|
+
private: string;
|
|
151
|
+
method: string;
|
|
152
|
+
bodyTooBig: string;
|
|
153
|
+
code: string;
|
|
154
|
+
setCookie: string;
|
|
155
|
+
noMaxAge: string;
|
|
156
|
+
};
|
|
157
|
+
export declare const CACHEABLE_METHODS: Set<string>;
|
|
158
|
+
/**
|
|
159
|
+
* When present, this query parameter will cause Layer0 to return a 412 status
|
|
160
|
+
* if a response could not be found in the cache.
|
|
161
|
+
*/
|
|
162
|
+
export declare const THROTTLED_QUERY_PARAM = "layer0_prefetch";
|
|
163
|
+
/**
|
|
164
|
+
* Same value as above but DEPRECATED.
|
|
165
|
+
*/
|
|
166
|
+
export declare const PREFETCH_QUERY_PARAM = "layer0_prefetch";
|
|
167
|
+
/**
|
|
168
|
+
Adds query parameter with custom maxAgeSecond value for service-worker cache if it's specified in PrefetchConfiguration
|
|
169
|
+
*/
|
|
170
|
+
export declare const PREFETCH_TTL_PARAM = "layer0_prefetch_ttl";
|
|
171
|
+
/**
|
|
172
|
+
Labels the request so that devtools will display as prefetched
|
|
173
|
+
*/
|
|
174
|
+
export declare const DEVTOOLS_PREFETCH_QUERY_PARAM = "layer0_dt_pf";
|
|
175
|
+
/**
|
|
176
|
+
* The name of the query parameter used to detect HEAD requests.
|
|
177
|
+
*/
|
|
178
|
+
export declare const HEAD_QUERY_PARAM = "layer0_head";
|
|
179
|
+
/**
|
|
180
|
+
* The name of the query parameter used for the body of POST requests, which is used for the cache key
|
|
181
|
+
*/
|
|
182
|
+
export declare const POST_BODY_QUERY_PARAM = "pref_layer0_body";
|
|
183
|
+
/**
|
|
184
|
+
* The name of the query parameter used for the method of requests, which is used for the cache key
|
|
185
|
+
*/
|
|
186
|
+
export declare const METHOD_QUERY_PARAM = "pref_layer0_method";
|
|
187
|
+
/**
|
|
188
|
+
* Route Group name, which is used in router for fallback routes
|
|
189
|
+
*/
|
|
190
|
+
export declare const ROUTES_FALLBACK = "fallback";
|
|
191
|
+
/**
|
|
192
|
+
* Route Group name, which is used in router for error page routes
|
|
193
|
+
*/
|
|
194
|
+
export declare const ROUTES_CATCH_GROUP = "catch";
|
|
195
|
+
/**
|
|
196
|
+
* Route Group name, which is used in router for noindex routes
|
|
197
|
+
*/
|
|
198
|
+
export declare const ROUTES_NOINDEX_GROUP = "noindex";
|
|
199
|
+
/**
|
|
200
|
+
* The path for the built-in image optimizer.
|
|
201
|
+
*/
|
|
202
|
+
export declare const LAYER0_IMAGE_OPTIMIZER_PATH = "/__layer0_image_optimizer";
|
|
203
|
+
/**
|
|
204
|
+
* Is current environment 'browser'
|
|
205
|
+
*/
|
|
206
|
+
export declare const IS_BROWSER: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Brotli encoding code.
|
|
209
|
+
*/
|
|
210
|
+
export declare const BROTLI_ENCODING = "br";
|
|
211
|
+
/**
|
|
212
|
+
* Gzip encoding code.
|
|
213
|
+
*/
|
|
214
|
+
export declare const GZIP_ENCODING = "gzip";
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Layer0 configuration file name.
|
|
5
|
+
*/
|
|
6
|
+
exports.LAYER0_CONFIG_FILE = 'layer0.config.js';
|
|
7
|
+
/**
|
|
8
|
+
* Indicate asset files that need to be uploaded under a different
|
|
9
|
+
* bucket key.
|
|
10
|
+
* It contains values like
|
|
11
|
+
* {
|
|
12
|
+
* '/posts' => '/posts/index.html'
|
|
13
|
+
* }
|
|
14
|
+
*/
|
|
15
|
+
exports.LAYER0_ASSET_ALIASES_FILE = 'asset-aliases.json';
|
|
16
|
+
/**
|
|
17
|
+
* Environment variables used by Layer0.
|
|
18
|
+
*/
|
|
19
|
+
exports.LAYER0_ENV_VARIABLES = {
|
|
20
|
+
/**
|
|
21
|
+
* Layer0 configuration environment variable key.
|
|
22
|
+
*/
|
|
23
|
+
config: 'LAYER0_CONFIG',
|
|
24
|
+
/**
|
|
25
|
+
* Indicates whether code is running locally or in the cloud.
|
|
26
|
+
* @private
|
|
27
|
+
*/
|
|
28
|
+
deploymentType: 'LAYER0_DEPLOYMENT_TYPE',
|
|
29
|
+
/**
|
|
30
|
+
* Allows Layer0 development team to easily override Layer0 version
|
|
31
|
+
* during development process.
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
versionOverride: 'LAYER0_VERSION_OVERRIDE',
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Indicates that code is running in AWS.
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
exports.LAYER0_DEPLOYMENT_TYPE_AWS = 'AWS';
|
|
41
|
+
/**
|
|
42
|
+
* Prefix of all Layer0 headers.
|
|
43
|
+
*/
|
|
44
|
+
exports.LAYER0_HEADERS_PREFIX = 'x-0-';
|
|
45
|
+
/**
|
|
46
|
+
* Maximum number of user headers allowed by Layer0 platform.
|
|
47
|
+
*
|
|
48
|
+
* We limit the request and response headers allowed to 70. This is due to a limitation that edge has
|
|
49
|
+
* which at the moment supports up to 96 headers. Edge provider itself needs to use some of those headers
|
|
50
|
+
* with the remainder used by our edge code.
|
|
51
|
+
*
|
|
52
|
+
* NOTE: This constant must be equal ot the constant of the same name defined in Layer0 buffer proxy.
|
|
53
|
+
* NOTE: If this constant is updated then the constant of the same name has to be updated in @layer0/build-lambda module.
|
|
54
|
+
*/
|
|
55
|
+
exports.LAYER0_MAX_USER_HEADERS_ALLOWED = 70;
|
|
56
|
+
/**
|
|
57
|
+
* Status code returned when there are too many request or response headers.
|
|
58
|
+
*
|
|
59
|
+
* Must be equal to HeaderOverflowError status code as defined in build lambda and Layer0 buffer proxy.
|
|
60
|
+
*/
|
|
61
|
+
exports.LAYER0_TOO_MANY_HEADERS_STATUS_CODE = 542;
|
|
62
|
+
/**
|
|
63
|
+
* The status code returned when the layer0_prefetch query param is present and a response could not be found in the cache.
|
|
64
|
+
*/
|
|
65
|
+
exports.LAYER0_UNCACHED_PREFETCH_STATUS = 412;
|
|
66
|
+
/**
|
|
67
|
+
* CDN-as-code configuration actions
|
|
68
|
+
*/
|
|
69
|
+
exports.ACTIONS = {
|
|
70
|
+
setHeader: 'set-header',
|
|
71
|
+
updateHeader: 'update-header',
|
|
72
|
+
removeHeader: 'remove-header',
|
|
73
|
+
syntheticRes: 'synthetic-response',
|
|
74
|
+
updatePath: 'update-path',
|
|
75
|
+
proxy: 'proxy',
|
|
76
|
+
addCookie: 'add-cookie',
|
|
77
|
+
updateCookie: 'update-cookie',
|
|
78
|
+
removeCookie: 'remove-cookie',
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* The backend for cloud functions
|
|
82
|
+
*/
|
|
83
|
+
exports.BACKENDS = {
|
|
84
|
+
js: '__js__',
|
|
85
|
+
static: '__static__',
|
|
86
|
+
permanentStatic: '__permanent_static__',
|
|
87
|
+
imageOptimizer: '__image_optimizer__',
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* The hostname used for the internal service running the user's application.
|
|
91
|
+
*/
|
|
92
|
+
exports.JS_BACKEND_HOSTNAME = '127.0.0.1';
|
|
93
|
+
exports.HTTP_METHODS = {
|
|
94
|
+
head: 'head',
|
|
95
|
+
get: 'get',
|
|
96
|
+
post: 'post',
|
|
97
|
+
delete: 'delete',
|
|
98
|
+
put: 'put',
|
|
99
|
+
patch: 'patch',
|
|
100
|
+
options: 'options',
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Common HTTP headers.
|
|
104
|
+
*/
|
|
105
|
+
exports.HTTP_HEADERS = {
|
|
106
|
+
acceptEncoding: 'accept-encoding',
|
|
107
|
+
authorization: 'authorization',
|
|
108
|
+
cacheControl: 'cache-control',
|
|
109
|
+
contentEncoding: 'content-encoding',
|
|
110
|
+
contentLength: 'content-length',
|
|
111
|
+
contentType: 'content-type',
|
|
112
|
+
cookie: 'cookie',
|
|
113
|
+
host: 'host',
|
|
114
|
+
location: 'location',
|
|
115
|
+
serverTiming: 'server-timing',
|
|
116
|
+
setCookie: 'set-cookie',
|
|
117
|
+
userAgent: 'user-agent',
|
|
118
|
+
vary: 'vary',
|
|
119
|
+
via: 'via',
|
|
120
|
+
x0Browser: 'x-0-browser',
|
|
121
|
+
x0CacheControl: 'x-0-cache-control',
|
|
122
|
+
x0CacheVersion: 'x-0-cache-version',
|
|
123
|
+
x0CachingStatus: 'x-0-caching-status',
|
|
124
|
+
x0ClientIp: 'x-0-client-ip',
|
|
125
|
+
x0Components: 'x-0-components',
|
|
126
|
+
x0Destination: 'x-0-destination',
|
|
127
|
+
x0Device: 'x-0-device',
|
|
128
|
+
x0DeviceIsBot: 'x-0-device-is-bot',
|
|
129
|
+
x0GeoCity: 'x-0-geo-city',
|
|
130
|
+
x0GeoCountryCode: 'x-0-geo-country-code',
|
|
131
|
+
x0GeoLatitude: 'x-0-geo-latitude',
|
|
132
|
+
x0GeoLongitude: 'x-0-geo-longitude',
|
|
133
|
+
x0GeoPostalCode: 'x-0-geo-postal-code',
|
|
134
|
+
x0MatchedRoutes: 'x-0-matched-routes',
|
|
135
|
+
x0Protocol: 'x-0-protocol',
|
|
136
|
+
x0Route: 'x-0-route',
|
|
137
|
+
x0Status: 'x-0-status',
|
|
138
|
+
x0SurrogateKey: 'x-0-surrogate-key',
|
|
139
|
+
x0T: 'x-0-t',
|
|
140
|
+
x0UserT: 'x-0-user-t',
|
|
141
|
+
x0Vendor: 'x-0-vendor',
|
|
142
|
+
x0Version: 'x-0-version',
|
|
143
|
+
xForwardedFor: 'x-forwarded-for',
|
|
144
|
+
xRequestId: 'x-request-id',
|
|
145
|
+
xSwCacheControl: 'x-sw-cache-control',
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Values for x-0-caching-status
|
|
149
|
+
*/
|
|
150
|
+
exports.CACHING_STATUS = {
|
|
151
|
+
ok: 'ok',
|
|
152
|
+
private: 'private',
|
|
153
|
+
method: 'method',
|
|
154
|
+
bodyTooBig: 'body-too-big',
|
|
155
|
+
code: 'code',
|
|
156
|
+
setCookie: 'set-cookie',
|
|
157
|
+
noMaxAge: 'no-max-age',
|
|
158
|
+
};
|
|
159
|
+
exports.CACHEABLE_METHODS = new Set(['get', 'head']);
|
|
160
|
+
/**
|
|
161
|
+
* When present, this query parameter will cause Layer0 to return a 412 status
|
|
162
|
+
* if a response could not be found in the cache.
|
|
163
|
+
*/
|
|
164
|
+
exports.THROTTLED_QUERY_PARAM = 'layer0_prefetch';
|
|
165
|
+
/**
|
|
166
|
+
* Same value as above but DEPRECATED.
|
|
167
|
+
*/
|
|
168
|
+
exports.PREFETCH_QUERY_PARAM = exports.THROTTLED_QUERY_PARAM;
|
|
169
|
+
/**
|
|
170
|
+
Adds query parameter with custom maxAgeSecond value for service-worker cache if it's specified in PrefetchConfiguration
|
|
171
|
+
*/
|
|
172
|
+
exports.PREFETCH_TTL_PARAM = 'layer0_prefetch_ttl';
|
|
173
|
+
/**
|
|
174
|
+
Labels the request so that devtools will display as prefetched
|
|
175
|
+
*/
|
|
176
|
+
exports.DEVTOOLS_PREFETCH_QUERY_PARAM = 'layer0_dt_pf';
|
|
177
|
+
/**
|
|
178
|
+
* The name of the query parameter used to detect HEAD requests.
|
|
179
|
+
*/
|
|
180
|
+
exports.HEAD_QUERY_PARAM = 'layer0_head';
|
|
181
|
+
/**
|
|
182
|
+
* The name of the query parameter used for the body of POST requests, which is used for the cache key
|
|
183
|
+
*/
|
|
184
|
+
exports.POST_BODY_QUERY_PARAM = 'pref_layer0_body';
|
|
185
|
+
/**
|
|
186
|
+
* The name of the query parameter used for the method of requests, which is used for the cache key
|
|
187
|
+
*/
|
|
188
|
+
exports.METHOD_QUERY_PARAM = 'pref_layer0_method';
|
|
189
|
+
/**
|
|
190
|
+
* Route Group name, which is used in router for fallback routes
|
|
191
|
+
*/
|
|
192
|
+
exports.ROUTES_FALLBACK = 'fallback';
|
|
193
|
+
/**
|
|
194
|
+
* Route Group name, which is used in router for error page routes
|
|
195
|
+
*/
|
|
196
|
+
exports.ROUTES_CATCH_GROUP = 'catch';
|
|
197
|
+
/**
|
|
198
|
+
* Route Group name, which is used in router for noindex routes
|
|
199
|
+
*/
|
|
200
|
+
exports.ROUTES_NOINDEX_GROUP = 'noindex';
|
|
201
|
+
/**
|
|
202
|
+
* The path for the built-in image optimizer.
|
|
203
|
+
*/
|
|
204
|
+
exports.LAYER0_IMAGE_OPTIMIZER_PATH = '/__layer0_image_optimizer';
|
|
205
|
+
/**
|
|
206
|
+
* Is current environment 'browser'
|
|
207
|
+
*/
|
|
208
|
+
exports.IS_BROWSER = typeof window !== 'undefined';
|
|
209
|
+
/**
|
|
210
|
+
* Brotli encoding code.
|
|
211
|
+
*/
|
|
212
|
+
exports.BROTLI_ENCODING = 'br';
|
|
213
|
+
/**
|
|
214
|
+
* Gzip encoding code.
|
|
215
|
+
*/
|
|
216
|
+
exports.GZIP_ENCODING = 'gzip';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides a context that can be used to store request
|
|
3
|
+
* state. For example, accumulating timing metrics from various layers
|
|
4
|
+
* during the life of the request.
|
|
5
|
+
*/
|
|
6
|
+
declare global {
|
|
7
|
+
module NodeJS {
|
|
8
|
+
interface Global {
|
|
9
|
+
__layer0_timings__: SingletonContext;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Runs the specified callback within the specified context
|
|
15
|
+
* @param cb
|
|
16
|
+
*/
|
|
17
|
+
export declare function withContext(cb: () => Promise<any>): any;
|
|
18
|
+
/**
|
|
19
|
+
* Gets a value from the current context
|
|
20
|
+
* @param key The name of the variable to get
|
|
21
|
+
* @param defaultValue A default value to set and return if no value is found.
|
|
22
|
+
*/
|
|
23
|
+
export declare function get(key: string, defaultValue: any): any;
|
|
24
|
+
/**
|
|
25
|
+
* Sets a value on the current context
|
|
26
|
+
* @param key The variable to set
|
|
27
|
+
* @param value The value to store
|
|
28
|
+
*/
|
|
29
|
+
export declare function set(key: string, value: any): void;
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
declare class SingletonContext {
|
|
34
|
+
values: any;
|
|
35
|
+
get(key: string): any;
|
|
36
|
+
set(key: string, value: any): void;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* This module provides a context that can be used to store request
|
|
4
|
+
* state. For example, accumulating timing metrics from various layers
|
|
5
|
+
* during the life of the request.
|
|
6
|
+
*/
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
const environment_1 = require("./environment");
|
|
12
|
+
const nonWebpackRequire_1 = __importDefault(require("./utils/nonWebpackRequire"));
|
|
13
|
+
const CONTEXT = 'layer0';
|
|
14
|
+
let clsNamespace;
|
|
15
|
+
/**
|
|
16
|
+
* Runs the specified callback within the specified context
|
|
17
|
+
* @param cb
|
|
18
|
+
*/
|
|
19
|
+
function withContext(cb) {
|
|
20
|
+
if (environment_1.isLocal()) {
|
|
21
|
+
return createClsNamespace().runAndReturn(cb);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
global.__layer0_timings__ = new SingletonContext();
|
|
25
|
+
return cb();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.withContext = withContext;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the current context.
|
|
31
|
+
*/
|
|
32
|
+
function getContext() {
|
|
33
|
+
return global.__layer0_timings__ || getClsNamespace();
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new CLS-hooked namespace
|
|
37
|
+
*/
|
|
38
|
+
function createClsNamespace() {
|
|
39
|
+
const cls = nonWebpackRequire_1.default('cls-hooked');
|
|
40
|
+
if (!clsNamespace) {
|
|
41
|
+
clsNamespace = cls.createNamespace(CONTEXT);
|
|
42
|
+
}
|
|
43
|
+
return clsNamespace;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Gets the current CLS-hooked namespace
|
|
47
|
+
*/
|
|
48
|
+
function getClsNamespace() {
|
|
49
|
+
return nonWebpackRequire_1.default('cls-hooked').getNamespace(CONTEXT);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Gets a value from the current context
|
|
53
|
+
* @param key The name of the variable to get
|
|
54
|
+
* @param defaultValue A default value to set and return if no value is found.
|
|
55
|
+
*/
|
|
56
|
+
function get(key, defaultValue) {
|
|
57
|
+
try {
|
|
58
|
+
const context = getContext();
|
|
59
|
+
let value = context.get(key);
|
|
60
|
+
if (value == null) {
|
|
61
|
+
value = defaultValue;
|
|
62
|
+
context.set(key, defaultValue);
|
|
63
|
+
}
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
return defaultValue;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.get = get;
|
|
71
|
+
/**
|
|
72
|
+
* Sets a value on the current context
|
|
73
|
+
* @param key The variable to set
|
|
74
|
+
* @param value The value to store
|
|
75
|
+
*/
|
|
76
|
+
function set(key, value) {
|
|
77
|
+
try {
|
|
78
|
+
getContext().set(key, value);
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
throw new Error('set must be called within withContext');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.set = set;
|
|
85
|
+
/**
|
|
86
|
+
*
|
|
87
|
+
*/
|
|
88
|
+
class SingletonContext {
|
|
89
|
+
constructor() {
|
|
90
|
+
this.values = {};
|
|
91
|
+
}
|
|
92
|
+
get(key) {
|
|
93
|
+
return this.values[key];
|
|
94
|
+
}
|
|
95
|
+
set(key, value) {
|
|
96
|
+
this.values[key] = value;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// This file was automatically added by layer0 init.
|
|
2
|
+
// You should commit this file to source control.
|
|
3
|
+
// Learn more about this file at https://docs.layer0.co/guides/layer0_config
|
|
4
|
+
module.exports = {
|
|
5
|
+
backends: {
|
|
6
|
+
origin: {
|
|
7
|
+
// The domain name or IP address of the origin server
|
|
8
|
+
domainOrIp: 'example.com',
|
|
9
|
+
|
|
10
|
+
// When provided, the following value will be sent as the host header when connecting to the origin.
|
|
11
|
+
// If omitted, the host header from the browser will be forwarded to the origin.
|
|
12
|
+
hostHeader: 'example.com',
|
|
13
|
+
|
|
14
|
+
// Uncomment the following line if TLS is not set up properly on the origin domain and you want to ignore TLS errors
|
|
15
|
+
// disableCheckCert: true,
|
|
16
|
+
|
|
17
|
+
// Overrides the default ports (80 for http and 443 for https) and instead use a specific port
|
|
18
|
+
// when connecting to the origin
|
|
19
|
+
// port: 1337,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
// The name of the site in Layer0 to which this app should be deployed.
|
|
24
|
+
// name: 'my-site-name',
|
|
25
|
+
|
|
26
|
+
// The name of the team in Layer0 to which this app should be deployed.
|
|
27
|
+
// team: 'my-team-name',
|
|
28
|
+
|
|
29
|
+
// Overrides the default path to the routes file. The path should be relative to the root of your app.
|
|
30
|
+
// routes: 'routes.js',
|
|
31
|
+
|
|
32
|
+
// The maximum number of URLs that will be concurrently prerendered during deployment when static prerendering is enabled.
|
|
33
|
+
// Defaults to 200, which is the maximum allowed value.
|
|
34
|
+
// prerenderConcurrency: 200,
|
|
35
|
+
|
|
36
|
+
// A list of glob patterns identifying which source files should be uploaded when running layer0 deploy --includeSources.
|
|
37
|
+
// This option is primarily used to share source code with Layer0 support personnel for the purpose of debugging. If omitted,
|
|
38
|
+
// layer0 deploy --includeSources will result in all files which are not gitignored being uploaded to Layer0.
|
|
39
|
+
//
|
|
40
|
+
// sources : [
|
|
41
|
+
// '**/*', // include all files
|
|
42
|
+
// '!(**/secrets/**/*)', // except everything in the secrets directory
|
|
43
|
+
// ],
|
|
44
|
+
|
|
45
|
+
// Allows you to include additional resources in the bundle that is deployed to Layer0’s serverless JS workers.
|
|
46
|
+
// Keys are globs, value can be a boolean or string. This is typically used to ensure that resources
|
|
47
|
+
// that need to be dynamically required at runtime such as build manifests for server-side rendering
|
|
48
|
+
// or other config files are present in the cloud.
|
|
49
|
+
//
|
|
50
|
+
// includeFiles: {
|
|
51
|
+
// 'lang/**/*': true, // Just includes the specified files
|
|
52
|
+
// 'content/**/*': 'another/dir/in/layer0/lambda', // Copies the files into specific directory within Layer0 build
|
|
53
|
+
// },
|
|
54
|
+
|
|
55
|
+
// Set to true to include all packages listed in the dependencies property of package.json when deploying to Layer0.
|
|
56
|
+
// This option generally isn't needed as Layer0 automatically includes all modules imported by your code in the bundle that
|
|
57
|
+
// is uploaded during deployment
|
|
58
|
+
//
|
|
59
|
+
// includeNodeModules: true,
|
|
60
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// This file was added by layer0 init.
|
|
2
|
+
// You should commit this file to source control.
|
|
3
|
+
|
|
4
|
+
import { Router } from '@layer0/core/router'
|
|
5
|
+
|
|
6
|
+
// const ONE_HOUR = 60 * 60
|
|
7
|
+
// const ONE_DAY = 24 * ONE_HOUR
|
|
8
|
+
|
|
9
|
+
export default new Router()
|
|
10
|
+
|
|
11
|
+
// Here is an example where we cache api/* at the edge but prevent caching in the browser
|
|
12
|
+
// .match('/api/:path*', ({ proxy, cache }) => {
|
|
13
|
+
// cache({
|
|
14
|
+
// edge: {
|
|
15
|
+
// maxAgeSeconds: ONE_DAY,
|
|
16
|
+
// staleWhileRevalidateSeconds: ONE_HOUR,
|
|
17
|
+
// },
|
|
18
|
+
// browser: {
|
|
19
|
+
// maxAgeSeconds: 0,
|
|
20
|
+
// serviceWorkerSeconds: ONE_DAY,
|
|
21
|
+
// },
|
|
22
|
+
// })
|
|
23
|
+
// proxy('origin')
|
|
24
|
+
// })
|
|
25
|
+
|
|
26
|
+
// send any unmatched request to origin
|
|
27
|
+
.fallback(({ proxy }) => proxy('origin'))
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// This file was added by layer0 init.
|
|
2
|
+
// You should commit this file to source control.
|
|
3
|
+
|
|
4
|
+
import { Router } from '@layer0/core/router'
|
|
5
|
+
|
|
6
|
+
// const ONE_HOUR = 60 * 60
|
|
7
|
+
// const ONE_DAY = 24 * ONE_HOUR
|
|
8
|
+
|
|
9
|
+
export default new Router()
|
|
10
|
+
|
|
11
|
+
// Here is an example where we cache api/* at the edge but prevent caching in the browser
|
|
12
|
+
// .match('/api/:path*', ({ proxy, cache }) => {
|
|
13
|
+
// cache({
|
|
14
|
+
// edge: {
|
|
15
|
+
// maxAgeSeconds: ONE_DAY,
|
|
16
|
+
// staleWhileRevalidateSeconds: ONE_HOUR,
|
|
17
|
+
// },
|
|
18
|
+
// browser: {
|
|
19
|
+
// maxAgeSeconds: 0,
|
|
20
|
+
// serviceWorkerSeconds: ONE_DAY,
|
|
21
|
+
// },
|
|
22
|
+
// })
|
|
23
|
+
// proxy('origin')
|
|
24
|
+
// })
|
|
25
|
+
|
|
26
|
+
// send any unmatched request to origin
|
|
27
|
+
.fallback(({ proxy }) => proxy('origin'))
|