From 92c276630f25067fe516d450f5200db9d8523830 Mon Sep 17 00:00:00 2001 From: pan261 Date: Mon, 24 Jan 2022 17:45:12 -0500 Subject: [PATCH] rearraged files and updated tsconfig --- package.json | 4 ++-- src/downloader.ts | 1 + src/{ => old}/taskRunner.ts | 45 ++++++++++++++++++------------------- src/{ => old}/watcher.ts | 2 +- src/webhooks.ts | 1 + tsconfig.json | 7 ++++-- 6 files changed, 32 insertions(+), 28 deletions(-) rename src/{ => old}/taskRunner.ts (77%) rename src/{ => old}/watcher.ts (98%) diff --git a/package.json b/package.json index 00ee711..cd51b70 100644 --- a/package.json +++ b/package.json @@ -4,10 +4,10 @@ "version": "1.0.0", "main": "/src/server.js", "scripts": { - "start": "node /src/server.js", + "start": "docker-compose up", "test": "echo \"Error: no test specified\" && exit 1", "tsc": "tsc", - "docker:build": "tsc && docker-compose up --build --remove-orphans" + "docker:build": "tsc --build && docker-compose up --build --remove-orphans" }, "repository": { "type": "git", diff --git a/src/downloader.ts b/src/downloader.ts index 18ac19a..8a78bfa 100644 --- a/src/downloader.ts +++ b/src/downloader.ts @@ -1,4 +1,5 @@ const fs = require('fs').promises; +const axios = require('axios'); const ForgeSDK = require('forge-apis'); const config = require('./config'); diff --git a/src/taskRunner.ts b/src/old/taskRunner.ts similarity index 77% rename from src/taskRunner.ts rename to src/old/taskRunner.ts index 8686fd7..0a84cb5 100644 --- a/src/taskRunner.ts +++ b/src/old/taskRunner.ts @@ -1,9 +1,8 @@ const axios = require('axios'); const watcher = require('./watcher'); -// const watcher2 = require('./watcher2') const downloader = require('./downloader'); const fs = require('fs'); -import * as config from './config'; +import * as config from '../config'; /** @@ -111,28 +110,28 @@ getCredentials(); /** * Function to dispatch the watcher */ -// const dispatchWatcher = async (interval: any) => { -// if (credentials === null) { -// console.log( -// '\x1b[93mtaskRunner.js::dispatchWatcher:', -// '\x1b[0mNo credentials' -// ); -// return; -// } +const dispatchWatcher = async (interval: any) => { + if (credentials === null) { + console.log( + '\x1b[93mtaskRunner.js::dispatchWatcher:', + '\x1b[0mNo credentials' + ); + return; + } -// const items = await watcher.watch(config.projectID, folderID, credentials, interval); + const items = await watcher.watch(config.projectID, folderID, credentials, interval); -// if (Object.keys(items).length == 0) { -// return; // no items to download -// } - -// for (var index in items) { -// // dispatch the downloader here -// downloader.download(items[index].location, items[index].name, __dirname + '/' + localDir, credentials); -// } -// }; + if (Object.keys(items).length == 0) { + return; // no items to download + } + + for (var index in items) { + // dispatch the downloader here + downloader.download(items[index].location, items[index].name, __dirname + '/' + localDir, credentials); + } +}; -// // There should be a buffer between how far back the watcher checks -// // and how often it runs. We may need to test this out. -// setInterval(dispatchWatcher, 5000, 7000); +// There should be a buffer between how far back the watcher checks +// and how often it runs. We may need to test this out. +setInterval(dispatchWatcher, 5000, 7000); diff --git a/src/watcher.ts b/src/old/watcher.ts similarity index 98% rename from src/watcher.ts rename to src/old/watcher.ts index 4824607..1e9ed3a 100644 --- a/src/watcher.ts +++ b/src/old/watcher.ts @@ -1,4 +1,4 @@ -const axios = require('axios'); +// const axios = require('axios'); /** * Kevin Pan | pan261@purdue.edu | Last Modified: 12/2/2021 diff --git a/src/webhooks.ts b/src/webhooks.ts index cea9053..738026d 100644 --- a/src/webhooks.ts +++ b/src/webhooks.ts @@ -10,6 +10,7 @@ const FileShareID = "urn:adsk.wipprod:fs.folder:co.T0n0mYQeS16K0lq1VuuYVQ" * Function to manage hook lifecycle */ exports.setup = (credentials: any) => { + console.log("checking hooks"); axios({ method: 'GET', url: 'https://developer.api.autodesk.com/webhooks/v1/hooks', diff --git a/tsconfig.json b/tsconfig.json index 0b315b7..7f1a7ff 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -25,7 +25,7 @@ /* Modules */ "module": "commonjs", /* Specify what module code is generated. */ - // "rootDir": "./", /* Specify the root folder within your source files. */ + "rootDir": "./src", /* Specify the root folder within your source files. */ // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ @@ -99,5 +99,8 @@ "skipLibCheck": true, /* Skip type checking all .d.ts files. */ "outDir": "./src/build", "sourceMap": true - } + }, + "exclude": [ + "./src/old" + ] }