Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .well-known/adobe/cloud-manager-challenge
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REPLACE-WITH-CLOUD-MANAGER-CHALLENGE-UUID
153 changes: 153 additions & 0 deletions aem-edge-functions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# Local secrets (never commit real secret values)
*.local

# Legacy tools
deploy

# aio
.aio

# system
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# fastly ignore
/node_modules
/bin
/pkg
52 changes: 52 additions & 0 deletions aem-edge-functions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# hal AEM Edge Functions

A Fastly Compute edge function for the **hal** Edge Delivery site, scaffolded
from the AEM Edge Functions boilerplate. It uses **folder mapping**: the page is authored once at
`/en/find-a-cruise/default` (DA: `/adobedevxsc/hal/en/find-a-cruise/default`)
and the handler (`src/find-a-cruise-handler.js`) renders that shell for every
`/en/find-a-cruise/<id>` URL, injecting per-id content — replace the boilerplate
injection with real logic.

Function source is under `./src`, tests under `./test` (run with `mocha`).
Service provisioning is defined in `../config/edgeFunctions.yaml` and CDN routing
in `../config/cdn.yaml`.

## How it runs (read this first)

- The function only runs on the **custom site domain** wired via
`../config/cdn.yaml` (the CDN origin-selector). It does **not** run on the
shared `*.aem.live` / `*.aem.page` hosts — those serve the normal EDS page.
- **Provisioning ≠ code deploy.** The function is *created* by the Cloud Manager
**Edge Delivery configuration pipeline** reading `/config` (edgeFunctions.yaml +
cdn.yaml) from the repo's `main` branch. `aio aem edge-functions deploy <name>`
only uploads code and fails "Edge Function not found" until the pipeline runs.

## Setup

```
npm install -g @adobe/aio-cli
aio plugins:install @adobe/aio-cli-plugin-aem-edge-functions
aio login
aio aem edge-functions setup # select the Sandbox 1 org + program; populates .aio
```

## Local development

```
npm install
npm run build # compiles ./src/index.js → ./bin/main.wasm
fastly compute serve # local runtime on :7676 (proxies non-demo paths to :3000)
```

Run `aem up` (the EDS dev server on :3000) alongside `fastly compute serve` so
the proxied shell requests resolve, then hit
`http://localhost:7676/en/find-a-cruise/anything`.

Or navigate to cd .../hal/aem-edge-functions and then run `aio aem edge-functions serve`.
Then open up `http://localhost:7676/en/find-a-cruise/anything`.

## Deploy (after the config pipeline has provisioned the function)

```
aio aem edge-functions deploy hal-edge-function
```
32 changes: 32 additions & 0 deletions aem-edge-functions/fastly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file describes a Fastly Compute package. To learn more visit:
# https://www.fastly.com/documentation/reference/compute/fastly-toml

authors = []
cloned_from = "https://github.com/fastly/compute-starter-kit-javascript-empty"
description = "hal AEM Edge Functions"
language = "javascript"
manifest_version = 3
name = "hal-edge-functions"
service_id = ""

[scripts]
build = "npm run build"
post_init = "npm install"

[local_server]
[local_server.backends]
# DEV ONLY: fetch the page shell from local `aem up` so local template/CSS
# changes show at :7676. Prod/preview use edgeFunctions.yaml (eds-prod/eds-preview).
[local_server.backends.eds-local]
url = "http://localhost:3000"

[local_server.config_stores]
[local_server.config_stores.config_default]
format = "inline-toml"
[local_server.config_stores.config_default.contents]
LOG_LEVEL = "debug"

[local_server.secret_stores]
[[local_server.secret_stores.secret_default]]
key = "API_TOKEN"
data = "helloworld"
Loading