Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pan261 committed Nov 22, 2021
1 parent 20e2718 commit c870893
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
32 changes: 14 additions & 18 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,18 @@ require('dotenv').config();

const ForgeSDK = require('forge-apis');

/*
Resources used:
https://forge.autodesk.com/developer/learn/threelegged-auth/understand-code
https://learnforge.autodesk.io/#/oauth/3legged/nodejs
https://www.npmjs.com/package/forge-apis
https://forge.autodesk.com/blog/3legged-token-process-nodejs-cli
Server running on port 3000 used to get 3-legged access token.
Must have FORGE_CLIENT_ID, FORGE_CLIENT_SECRET, and FORGE_CALLBACK_URL set in .env file.
FORGE_CALLBACK_URL (should be 'http://localhost:3000/callback/') should be the same in the .env
and in the Forge API project console.
Usage: node test.js or npm start
Navigate to http://localhost:3000/auth/ to get started
Browser should then go through the Autodesk Auth screen and display Auth token.
*/
/**
* Kevin Pan | pan261@purdue.edu | Last Modified: 11/22/2021
*
* Authentication server used to perform 3-legged auth through browser.
*
* Uses environment variables:
* - FORGE_CLIENT_ID
* - FORGE CLIENT_SECRET
* - FORGE_CALLBACK_URL
* - PORT (defaults to 3000)
*
*/

const scopes = ['bucket:create', 'bucket:read', 'data:read', 'data:create', 'data:write'];

Expand All @@ -42,7 +38,7 @@ let intervalID = null;
* - after consent screen, auth API will redirect headers
* 3. /credentials
* - will return credentials JSON object or null if there isn't one
* @returns server object
* @returns express server object
*/
const createServer = () => {
const app = express();
Expand Down Expand Up @@ -123,7 +119,7 @@ const createServer = () => {
}

/**
* Used to refresh tokens
* Used internally to refresh tokens automatically
*/
const refresh = () => {
oAuth2ThreeLegged.refreshToken(credentials, scopes)
Expand Down
3 changes: 2 additions & 1 deletion taskRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ const watcher = require('./watcher');
require('dotenv').config();

/**
* Kevin Pan | pan261@purdue.edu | Last Modified: 11/22/2021
*
* This file will be responsible for managing the watcher
* as well as fetching the credentials from the server
* docker-compose will spawn 4 services from this file, each responsible
* for a different folder (gantry, lathe, mill, waterjet)
*/


// TODO
const projectID = ""

Expand Down
7 changes: 5 additions & 2 deletions watcher.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const axios = require('axios');

/**
* Watches given folder id in the project, dispatches downloader for any files needing to be updated
* Kevin Pan | pan261@purdue.edu | Last Modified: 11/22/2021
*
* Watches given folder id in the project, logs any files changed since
* `interval` ms ago
* @param {String} projectId the project id
* @param {String} folderId the folder id
* @param {Object} credentials credentials for the call
* @param {Integer} interval number of ms used to filter the date
* if an interval is not passed, watcher will loop through all files in the folder
* if an interval is not passed, watcher will return all files in the given folder
*/
exports.watch = (projectID, folderID, credentials, interval) => {
let timeFilter = {};
Expand Down

0 comments on commit c870893

Please sign in to comment.