Skip to content

wallabyway/viewer-serverless

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ForgeViewer-Serverless

Live Demo: https://adc6qwtnce.execute-api.us-east-1.amazonaws.com/tutorial/

YouTube: demo

updateForgeGif

This is the 'hello world' example of Autodesk Forge Viewer deployed to AWS-Lambda... aka 'Serverless'.

To simplify deploy to AWS-Lambda, I use 'Claudia.js'. The backend stack is Node.js / Express.

Below I demonstrate 'Claudia.js' 'update' command to re-deploy a small html code change. Claudia handles the task of zipping, uploading and re-wiring node.js endpoints to 'AWS-Lambda & API-Gateway' automatically.

Getting Started

Before you start, make sure you have npm and AWS credentials setup.

  1. Run npm install
  2. Run npm run create to send everything up to AWS Lambda. It will return a 'new URL'.
  3. Edit the file package.json and update the variables FORGE_CLIENT_ID=xxx,FORGE_CLIENT_SECRET=xxx,FORGE_URN=xxx with your own Forge values.
  4. Run npm run setvars to push the environment variables to Lambda.
  5. Open the 'new URL' in a browser

Example: https://adc6qwtnce.execute-api.us-east-1.amazonaws.com/tutorial/

Remember to add a '/' or a '/index.html' to the URL.

Updating the app

  1. Make a code change to file 'www/index.html'
  2. Run npm run update... It output a 'new URL'
  3. Open the 'new URL' in a Browse to see your changes.

Make sure LINE#38 in app.js is commented out

Debugging locally

  1. Uncomment line 38, in app.js
  2. Add your Forge Environment variables. Similar to this...
export FORGE_CLIENT_ID=lDB........0Ol
export FORGE_CLIENT_SECRET=f...H
export FORGE_URN= dXJu........QucnZ0

  1. start the server with ...

> node app.js

  1. Open localhost:3000/ in a browser
  2. Make some code changes

For more information

This code came from GITHUB-Express-Lambda

More information on Express/Serverless can be found here: Running Express Apps in AWS Lambda

The package.json was modified from here: Package.json

Why use Claudia?

Inspired by this blog post, by Philippe Leefsma.