GithubHelp home page GithubHelp logo

autodesk-forge / forge-boilers.nodejs Goto Github PK

View Code? Open in Web Editor NEW
68.0 19.0 53.0 35.57 MB

DEPRECATED, please use https://github.com/Autodesk-Forge/learn.forge.viewmodels

Home Page: http://learnforge.autodesk.io/#/tutorials/viewmodels

License: MIT License

JavaScript 67.61% HTML 1.63% Shell 0.04% CSS 30.72%

forge-boilers.nodejs's Introduction

This package is now deprecated

For boilerplate projects for node.js and other languages, please see http://learnforge.autodesk.io and its source code https://github.com/Autodesk-Forge/learn.forge.viewmodels.

Forge Node.js Boilers

Node.js npm License

oAuth2 Data-Management OSS Model-Derivative

Description

A collection of node.js-based boiler projects for the Autodesk Forge Web Services APIs.

Those samples illustrates how to use the following Forge npm packages:

Prerequisites

To run those samples, you need your own Forge API credentials:

Boilers Setup

Below are instructions to setup and run locally each boiler project, they may vary based on which project you want to run.

Project #1 - viewer-offline

You can simply open viewer-offline.html in a browser. This project will load the local model from /v8 directoryand does not require you to run any server on the machine, although you may want to serve the .html page to get around security restrictions imposed by some browsers (such as Chrome) when reading local files.

  • In order to do that install a local http server on your machine, you can use the following:

    sudo npm install -g http-server

  • Navigate to "/1 - viewer-offline" directory and start the server:

    http-server

  • Note the local address output by the server (ex: http://127.0.0.1:8080) and type in your browser: http://127.0.0.1:8080/viewer-offline.html

  • This project does not require any internet connection or Forge API credentials and can be used for testing the viewer API locally

  • You can also run that sample the following links, which in that case requires an internet connection:

Thumbnail

thumbnail

Project #2 - viewer-barebone

Samples in this project do not require you to implement a server, but they rely on hardcoded token and URN in the JavaScript code, so they are for testing purpose only.

  • You will need to generate a valid 2-legged OAuth token and upload a model to your account, which you can do using that website for now: https://models.autodesk.io

  • Once you have a token and the URN of your model, replace in the hardcoded fields in viewer.html and viewingApp.html:

    var token = '<< Place your token here >>'

    var urn = '<< Place your URN here >>'

  • You can open the files directly in browser or serve similar to project #1. The viewer.html is using the plain JavaScript viewer API, whereas viewingApp.html is using an extra layer of code from Autodesk which adds a UI to switch between viewables (for designs translated from Revit .rvt files), see screenshot below:

Multiple Views

Project #3 - viewer+server

Project #4 - viewer+server+oss

Project #5 - viewer+server+oss+derivatives

The setup is similar for those 3 projects and they have to be run independently.

Those projects are using Webpack, a module bundler and NPM packages to build and generate the frontend code, so an extra build step is required.

Navigate with a command shell or terminal to the project you want to run and type the following commands:

Mac OSX/Linux (Terminal)

> npm install
> export NODE_ENV=development
> export FORGE_DEV_CLIENT_ID=<YOUR CLIENT ID FROM DEVELOPER PORTAL>
> export FORGE_DEV_CLIENT_SECRET=<YOUR CLIENT SECRET>
> npm start (builds the client dynamically in memory using webpack dev server)

Windows (use Node.js command line from Start menu)

> npm install
> set NODE_ENV=development
> set FORGE_DEV_CLIENT_ID=<YOUR CLIENT ID FROM DEVELOPER PORTAL>
> set FORGE_DEV_CLIENT_SECRET=<YOUR CLIENT SECRET>
> npm start (builds the client dynamically in memory using webpack dev server)

Open your browser at: http://localhost:3000

To run a production build you can use build command:

> npm run build

A production build code is minified and function names are mangled which make it much smaller and impractical for debugging or reverse engineering.

Deploy Project #5 on Heroku

To deploy this project to Heroku, simply click on the button below, at the Heroku Create New App page:

  • Set your Client ID & Client Secret with your Forge API keys

Deploy

The result will look like below: a treeview of the OSS storage that lets you upload designs and perform actions from the context menu.

To load a design in the viewer:

  • Right-click the root node to create a new bucket if you do not have any
  • Upload the design file to the bucket (supports file selection dialog or drag & drop)
  • Upon successful upload, the file appears in the bucket, right-click and select Generate viewable
  • Upon successful translation of the design, double-click the file and it will get loaded in the viewer

Live Demo

https://oss.autodesk.io

Project5

Project #6 - viewer+server+data-mng+derivatives

Same setup than for projects #3, #4, #5 but you also need a valid callback url to achieve 3-legged oauth authentication. I recommend you create 2 sets of Forge API keys, one for DEVELOPMENT and one for PRODUCTION because each set has a different callback url.

To run the project locally (using the DEV API keys):

forge-dev

Run the following commands (mind the DEV!):

> npm install
> npm set NODE_ENV=development
> set FORGE_DEV_CLIENT_ID=<YOUR DEV CLIENT ID FROM DEVELOPER PORTAL>
> set FORGE_DEV_CLIENT_SECRET=<YOUR DEV CLIENT SECRET>
> npm start (builds the client dynamically in memory using webpack dev server)

To run in production, the callback url defined in your Forge App needs to match the host url, so if you run your app from https://mydomain.com:

> npm install
> set HOST_URL=https://mydomain.com
> npm set NODE_ENV=production
> set FORGE_CLIENT_ID=<YOUR CLIENT ID FROM DEVELOPER PORTAL>
> set FORGE_CLIENT_SECRET=<YOUR CLIENT SECRET>
> npm start (builds the client dynamically on disk or use npm run build before)

Deploy Project #6 on Heroku

To deploy this project to Heroku, simply click on the button below, at the Heroku Create New App page:

Deploy

The result will look like below: a treeview of your Autodesk Cloud storage that lets you upload designs and perform actions from the context menu.

To load a design in the viewer:

  • Right-click the nodes to get options from the context menu
  • Upload a design file to a folder (supports file selection dialog or drag & drop)
  • Upon successful upload, the file appears under the parent node in the tree, right-click and select Generate viewable
  • Upon successful translation of the design, double-click the file and it will get loaded in the viewer

Live Demo

https://dm.autodesk.io

Project6

License

MIT License

Written by

Written by Philippe Leefsma

Forge Partner Development - http://forge.autodesk.com

forge-boilers.nodejs's People

Contributors

augustogoncalves avatar jaylimboonkiat avatar kimekeunkyung avatar leefsmp avatar petrbroz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

forge-boilers.nodejs's Issues

npm start runs into ERR!

I try to start npm and ran into an error, i'am an absolute rookie and have no idea what's the problem.
Maybe some one can bring some light into my darkness.

TypeError: Cannot read property 'toLowerCase' of undefined
at Object. (C:\Users\Lieme\Desktop\Python Learning\viewer-walkthrough-online.viewer-master\start.js:106:35)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: node start.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Deprecated in favor of learnforge?

@augustogoncalves, @cyrillef,

I would suggest that we deprecate this repository in favor of https://github.com/Autodesk-Forge/learn.forge.viewmodels, because:

  • It's using SDKs that are deprecated (for example, https://github.com/Autodesk-Forge/forge.oauth2-js or https://github.com/Autodesk-Forge/forge.oss-js)
  • It includes examples of serving Forge Viewer assets from custom origins which is not allowed by our licensing terms
  • I would say that http://learnforge.autodesk.io provides more up-to-date boilerplate projects for Node.js as well as other languages
  • In my opinion, some of the boilerplates here are quite heavy
    • For example, the boilerplate for a 3 - viewer+server includes 36 npm dependencies, incl. webpack, babel, etc.
    • I believe boilerplate projects should be as lightweight as possible

What do you think?

Problem with project 6

I'm trying to run project number 6.

I set the CallBack URL in the app to: http://localhost:3000/api/forge/callback/oauth
And the environment variables for the id and secret.
And: set HOST_URL=http://localhost:3000

But when I navigate to http://localhost:3000 and press User Data I get a popup with the following message in it:

{"developerMessage":"The required parameter(s) client_id not present in the request","userMessage":"","errorCode":"AUTH-008","more info":"http://developer.api.autodesk.com/documentation/v1/errors/AUTH-008"}

Did I miss something?

Error running 'npm install' in Node.js command line

Hi!

I am getting some ERR! as I try to run the install. Is it supposed to look like this, or am I doing something wrong?

`

C:\Users\tgrim\Downloads\1\1>npm install
[email protected] postinstall C:\Users\tgrim\Downloads\1\1
npm run install-boiler5
[email protected] install-boiler5 C:\Users\tgrim\Downloads\1\1
npm install --prefix ./5\ -\ viewer+server+oss+derivatives
npm ERR! code EINVALIDTAGNAME
npm ERR! Invalid tag name "viewer+server+oss+derivatives": Tags may not have any characters that encodeURIComponent encodes.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\tgrim\AppData\Roaming\npm-cache_logs\2017-07-26T19_10_35_097Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install-boiler5: npm install --prefix ./5\ -\ viewer+server+oss+derivatives
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install-boiler5 script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\tgrim\AppData\Roaming\npm-cache_logs\2017-07-26T19_10_35_341Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: npm run install-boiler5
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\tgrim\AppData\Roaming\npm-cache_logs\2017-07-26T19_10_35_604Z-debug.log`

Boiler Project #5 - Errors getting and creating buckets

Hi there,

I am trying to run the Boiler Project 5 in development config.

I have installed dependencies and set my environment variables -webpack builds successfully.

When loading localhost:3000 I see these errors in chrome console:

get-error

Any idea what would be causing this?

Projects 4,5 don't work locally

I'm trying to run project 5 locally, everything was green when running npm run build-dev, but after npm run dev and navigating to localhost:3000, I get a very long message that ends with:

developerMessage: 'The client_id specified does not have access to the api product',
userMessage: '',
errorCode: 'AUTH-001',
'more info': 'http://developer.api.autodesk.com/documentation/v1/errors/AUTH-001' } }

And nothing has changed in the watcher window.

I have all the APIs in the app ticked on and my id and secret do work in other projects.

And project 4, I see my buckets on the left, but it looks like the download or upload buttons don't do anything and nothing shows up on the main panel which I assume is the viewer.

And I get the following error after a few seconds of pressing the buttons:

TypeError: First argument must be a string or Buffer
at ServerResponse.OutgoingMessage.write (_http_outgoing.js:456:11)
at writetop (C:\forge-boilers.nodejs-master\4 - viewer+server+oss\node_modules\express-session\index.js:296:22)
at ServerResponse.end (C:\forge-boilers.nodejs-master\4 - viewer+server+oss\node_modules\express-session\index.js:351:16)
at C:/forge-boilers.nodejs-master/4 - viewer+server+oss/src/server/api/endpoints/oss.js:166:11
at next (native)
at step (C:\forge-boilers.nodejs-master\4 - viewer+server+oss\src\server\api\endpoints\oss.js:19:191)
at C:\forge-boilers.nodejs-master\4 - viewer+server+oss\src\server\api\endpoints\oss.js:19:361
at process._tickCallback (internal/process/next_tick.js:103:7)
uncaughtException
TypeError: First argument must be a string or Buffer
at ServerResponse.OutgoingMessage.end (_http_outgoing.js:555:11)
at writeend (C:\forge-boilers.nodejs-master\4 - viewer+server+oss\node_modules\express-session\index.js:261:22)
at Immediate.ontouch (C:\forge-boilers.nodejs-master\4 - viewer+server+oss\node_modules\express-session\index.js:348:11)
at runCallback (timers.js:637:20)
at tryOnImmediate (timers.js:610:5)
at processImmediate [as _immediateCallback] (timers.js:582:5)
TypeError: First argument must be a string or Buffer
at ServerResponse.OutgoingMessage.end (_http_outgoing.js:555:11)
at writeend (C:\forge-boilers.nodejs-master\4 - viewer+server+oss\node_modules\express-session\index.js:261:22)
at Immediate.ontouch (C:\forge-boilers.nodejs-master\4 - viewer+server+oss\node_modules\express-session\index.js:348:11)
at runCallback (timers.js:637:20)
at tryOnImmediate (timers.js:610:5)
at processImmediate [as _immediateCallback] (timers.js:582:5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.