Skip to content

Commit

Permalink
rearraged files and updated tsconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
pan261 committed Jan 24, 2022
1 parent c046ee3 commit 92c2766
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 28 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/downloader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const fs = require('fs').promises;
const axios = require('axios');
const ForgeSDK = require('forge-apis');
const config = require('./config');

Expand Down
45 changes: 22 additions & 23 deletions src/taskRunner.ts → src/old/taskRunner.ts
Original file line number Diff line number Diff line change
@@ -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';


/**
Expand Down Expand Up @@ -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);

2 changes: 1 addition & 1 deletion src/watcher.ts → src/old/watcher.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const axios = require('axios');
// const axios = require('axios');

/**
* Kevin Pan | pan261@purdue.edu | Last Modified: 12/2/2021
Expand Down
1 change: 1 addition & 0 deletions src/webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
7 changes: 5 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -99,5 +99,8 @@
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
"outDir": "./src/build",
"sourceMap": true
}
},
"exclude": [
"./src/old"
]
}

0 comments on commit 92c2766

Please sign in to comment.