Global Navigation

  • Products
  • Overview
  • Getting Started
  • Guides
  • Resources
  • Console

Table of Contents

  • Introduction
    • App Builder Overview
    • What is App Builder
    • Business Case
    • FAQ
    • Community
  • Quick Start
    • App Builder Getting Started
      • Setting Up
      • Creating your First App
      • Publishing Your App
      • Troubleshooting
    • Runtime Getting Started
      • Overview
      • Activations
      • Deploy
      • Entities
      • How Runtime Works
      • Resources
      • Setup
      • Understanding Runtime
  • Develop
    • References
    • App Builder Guides
      • Architecture Overview
        • App Hooks
        • Introduction to React Spectrum
        • Using SDKs
      • Application State
      • Application Logging
        • Azure Log Analytics
        • New Relic
        • Splunk Cloud
        • Splunk Enterprise
      • Configuration
        • Webpack Configuration
      • Deployment
        • CI/CD for App Builder Apps
        • Credential Rotation
        • Setting Response Headers
      • Development
      • Distribution
      • Events
        • Webhooks
      • Exc App
        • Interfaces
          • Modules
          • Page ObjectWithHref
          • Page ObjectWithPath
          • Page PageAPI
          • Page PageAPIProperties
          • Runtime
          • TopBar Callback
          • TopBar CustomFeedbackConfig
          • TopBar CustomSearchConfig
          • TopBar ExternalFeedbackConfig
          • TopBar HelpCenterFeedbackConfig
          • TopBar Solution
          • TopBar TopBarAPI
          • TopBar TopBarAPIProperties
          • User UserAPI
          • User UserInfo
        • Migrate App to Exp Cloud SPA
        • Modules
          • Page
          • TopBar
          • User
      • Extensions
        • Extension Migration Guide
      • Optimization
      • Security
        • Understanding Authentication
      • Telemetry
    • Runtime Guides
      • Contribution Guide
      • Asynchronous Calls
      • Creating Actions
      • Creating REST APIs
      • CI/CD Pipeline
      • Debugging
      • Logging & Monitoring
      • Reference Docs
        • API Reference
        • CLI Usage
        • Configuring Proxy
        • Environment Variables
        • Feeds
        • Multiple Regions
        • Packages
        • Prepackages
        • Runtimes
        • Sequences & Compositions
        • Triggers & Rules
        • WSK Usage
      • Security General
      • Securing Web Actions
      • System Settings
      • Throughput Tuning
      • Tools
        • CLI Install
      • Troubleshooting
      • Using Packages
      • Using Runtime
    • Contribution Guide
  • Learning
    • Asset Compute Worker PS API
      • Requirements
      • Lesson 1: Create an app from Asset Compute template
      • Lesson 2: Configure the app
      • Lesson 3: Develop worker calling Photoshop API
      • Lesson 4: Integrate worker in AEMaaCS
      • Well done
    • Barcode Reader
      • Requirements
      • Lesson 1: Bootstrap a Headless App
      • Lesson 2: Writing a Serverless Action
      • Lesson 3: Unit and E2E Tests
      • Well done
    • Blog Articles
      • Blog Articles
    • CI/CD
      • Requirements
      • Lesson 1: Setup CI/CD
      • Lesson 2: Monitoring CI/CD
      • Lesson 3: Custom CI/CD workflow
      • Well done
    • Cron Jobs
      • Requirements
      • Lesson 1: Bootstrap a Headless App
      • Lesson 2: Set up Alarm Feed with Trigger and Rule
      • Lesson 3: Types of Alarm Feed
      • Well done
    • Custom Asset Compute Worker
      • Requirements
      • How AEM as Cloud assets works
      • Architecture of our worker
      • Configure services
      • Local environment setup
      • Implement the worker
      • Test the worker
      • Setup AEM to use the worker
      • Well Done
    • Customer Dashboard
      • Requirements
      • Lesson 1: Create a New App Builder App from Campaign Standard Template
      • Lesson 2: Explore the App Builder App
      • Lesson 3: Run the App Builder App Locally
      • Lesson 4: List All Customer Profiles on the UI
      • Lesson 5: Add Personalized Promotion Emails Triggering
      • Well Done
    • Debugging
      • Requirements
      • Lesson 1: Getting familiar with Debugger
      • Lesson 2: Debugging Application Code
      • Lesson 3: Managing Application Logs
      • Well Done
    • Event Driven
      • Requirements
      • Lesson 1: Create a New App Builder App from Template
      • Lesson 2: Register the App as Event Provider
      • Lesson 3: Fire an Event
      • Lesson 4: Consume Events
      • Well Done
    • Events Runtime
      • Requirements
      • Lesson 1: Step by Step Guide
      • Lesson 2: Verify the result
      • Well done
    • Journaling Events
      • Requirements
      • Lesson 1: Create an Event Provider using App Builder
      • Lesson 2: Create the Event Consumer using Journaling API
      • Lesson 3: End to end test
      • Well done
    • Sample Apps
      • Code Snippets
        • Caching HTTP responses
        • App Builder Files SDK
        • App Builder State SDK
        • I/O Events handler
        • Real-time data from Adobe Analytics API 1.4
    • Spectrum Introduction
      • Lesson 1: What is Spectrum ?
      • Lesson 2: Using Spectrum CSS
      • Lesson 3: Using React Spectrum
      • Lesson 4: Using React Spectrum in App Builder
      • Well done
    • Todo App
      • Requirements
      • Lesson 1: Create a New App Builder App with the React Spectrum template
      • Lesson 2: Setup Runtime actions
      • Lesson 3: Setup the CreateTodoList component
      • Lesson 4: Setup the Todo component
      • Lesson 5: Setup the TodoList component
      • Lesson 6: Bringing the pieces together to build the App
      • Well done
    • Videos
      • Overview
        • Introducing App Builder
        • Getting Started
        • Architecture
        • A Full Security Overview
        • User Journey
      • Exploring
        • Projects and Workspaces
        • React Spectrum
        • Custom Events
        • CI/CD
        • Debugging
        • Learning Resources
        • Dashboard Case Study
        • ODE Case Study
        • Deep Dive Use Cases
        • Live Wired Sneak
        • Softcrylic Partner Showcase
      • Developers Live
        • App Builder Deep Dive
        • Asset Compute Service Extensibility
        • Extend Adobe Experience Cloud
  1. Products
  2. Overview
  3. Resources
  4. Learning
  5. Barcode Reader
  6. Lesson 1: Bootstrap a Headless App

Lesson 1: Bootstrap a Headless App Builder App

In order to create your barcode application, use the following command:

aio app init my-barcode-app --no-extensions

We select the org, project and workspace for our app, and then be presented with a few options what you want your app to include, for example Serverless Actions, Web UI, CI/CD pipeline, and I/O Events. Since we are building a headless app, we're only interested in using Actions: Deploy Runtime actions.

cli1

The second question the CLI asks is which experience cloud or experience platform apps you want to extend or build. In this case, we're going to choose Generic.

cli2

To the third question, we'll specify the action name barcode.

cli3

From the command line, we are creating a Developer project with everything it needs, from the serverless actions, configuration files, tests, etc.

cli3

We didn't include the UI setup, CI/CD pipeline, nor I/O Events. These topics will be covered in other Code Labs.

For our barcode app, we'll start by modifying the following files:

app.config.yaml, which contains all defined actions with their default parameters:

application: actions: actions web: web-src runtimeManifest: packages: my-app: license: Apache-2.0 actions: generic: function: actions/generic/index.js web: 'yes' runtime: 'nodejs:14' inputs: LOG_LEVEL: debug annotations: require-adobe-auth: true final: true

package.json, which holds your app name, version and all dependencies that will be bundled when deploying the barcode action:

{ "name": "my-barcode-app", "version": "0.0.1", "dependencies": { "@adobe/aio-sdk": "^2.1.0", "node-fetch": "^2.6.0" }, "devDependencies": { "jest": "^24.9.0", "@adobe/wskdebug": "^1.1.0" }, "scripts": { "test": "jest", "e2e": "jest --collectCoverage=false --testRegex ./e2e" } }

.env should not be committed, since this is where you'll store your Adobe I/O Runtime secrets (namespace and auth):

# Specify your secrets here # This file should not be committed to source control ## please provide your Adobe I/O Runtime credentials # AIO_RUNTIME_AUTH= # AIO_RUNTIME_NAMESPACE=

actions/barcode/index.js is the source code of your barcode action:

/* * <license header> */ /** * This is a sample action showcasing how to access an external API */ const { Core } = require('@adobe/aio-sdk') const fetch = require('node-fetch') const { errorResponse, getBearerToken, stringParameters, checkMissingRequestInputs } = require('../utils') // main function that will be executed by Adobe I/O Runtime async function main (params) { // create a Logger const logger = Core.Logger('main', { level: params.LOG_LEVEL || 'info' }) try { // 'info' is the default level if not set logger.info('Calling the main action') // log parameters, only if params.LOG_LEVEL === 'debug' logger.debug(stringParameters(params)) // check for missing request input parameters and headers const requiredParams = [/* add required params */] const errorMessage = checkMissingRequestInputs(params, requiredParams, ['Authorization']) if (errorMessage) { // return and log client errors return errorResponse(400, errorMessage, logger) } // extract the user Bearer token from the input request parameters const token = getBearerToken(params) // replace this with the api you want to access const apiEndpoint = 'https://adobeioruntime.net/api/v1/api-docs' // fetch content from external api endpoint const res = await fetch(apiEndpoint) if (!res.ok) { throw new Error('request to ' + apiEndpoint + ' failed with status code ' + res.status) } const content = await res.json() logger.debug('fetch content = ' + JSON.stringify(content, null, 2)) const response = { statusCode: 200, body: content } // log the response status code logger.info(`${response.statusCode}: successful request`) return response } catch (error) { // log any server errors logger.error(error) // return with 500 return errorResponse(500, 'server error', logger) } } exports.main = main