transform.ts
Is run on Layer0 Serverless, AWS Lambda. Is used to transform responses (and requests).
By default, this file is not referenced in the code.
Using this in production may (or most probably) result in 539, project timeouts. As this runs on AWS Lambda, if not cached, a high traffic might just touch the timeout limit.
But in case you are just craving to try out this transform, here's you can enable it:
-
In
shoppingFlowRouteHandler.ts
, make the following changes:
shoppingFlowRouteHandler.ts
+ import transformResponse from './transform'
- proxy('origin')
+ proxy('origin', { transformResponse } )
-
Hit any matching route inside
routes.ts
that references to shoppingFlowRouteHandler, for e.g.:
routes.ts
.match('/', shoppingFlowRouteHandler)
-
Load the matched route and see that it contains two more HTML tags inside the
<head>
tag:
page.html
<script src="/__layer0__/cache-manifest.js" defer="defer"></script>
<script src="/__layer0__/main.js" defer="defer"></script>
As you can see, the following code inside the tranform.ts adds those two tags:
transform.ts
// Those 2 scripts are added using server side transformation just for Proof of Concept purposes.
// For production these scripts should be included in original website base code.
$('head').append(`
<script src="/__layer0__/cache-manifest.js" defer="defer"></script>
<script src="/__layer0__/main.js" defer="defer"></script>
`)
Edit this page on GitHub
Updated at Tue, Jun 21, 2022