From c870893d4633e32e8d33d08ca0dccdcb47ce452a Mon Sep 17 00:00:00 2001 From: pan261 Date: Mon, 22 Nov 2021 13:46:08 -0500 Subject: [PATCH] comments --- server.js | 32 ++++++++++++++------------------ taskRunner.js | 3 ++- watcher.js | 7 +++++-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/server.js b/server.js index 3ffef8c..bf079d6 100644 --- a/server.js +++ b/server.js @@ -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']; @@ -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(); @@ -123,7 +119,7 @@ const createServer = () => { } /** - * Used to refresh tokens + * Used internally to refresh tokens automatically */ const refresh = () => { oAuth2ThreeLegged.refreshToken(credentials, scopes) diff --git a/taskRunner.js b/taskRunner.js index a361525..47e7144 100644 --- a/taskRunner.js +++ b/taskRunner.js @@ -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 = "" diff --git a/watcher.js b/watcher.js index e439dcb..1b78f7a 100644 --- a/watcher.js +++ b/watcher.js @@ -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 = {};