Skip to content

Commit

Permalink
update tsconfig and fix iexecOut
Browse files Browse the repository at this point in the history
  • Loading branch information
FerrariAndrea committed Sep 7, 2022
1 parent 6da6232 commit 91d9f9a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 26 deletions.
2 changes: 1 addition & 1 deletion DApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"clean": "rimraf build",
"build": "tsc",
"start": "node build/app.js",
"start": "node build/src/app.js",
"test": "cd tests && npx jest",
"lint": "eslint . --ext .ts",
"onchain:deploy": "iexec app deploy --chain viviani",
Expand Down
11 changes: 10 additions & 1 deletion DApp/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,20 @@ process.on('unhandledRejection', error => {
//params: requestID + ' | ' + query,
const _run = async ()=>{
try{

var iexecOut= process.env.IEXEC_OUT;
if (iexecOut === undefined || iexecOut.trim().length===0) {
iexecOut = Conf.DEFAULT_IEXEC_OUT;
}

logger.addLog("APP",JSON.stringify(process.argv));
const requestID =process.argv[2].trim();
const query =process.argv[3].trim().replace(/__!_/gm,"\"").replace(/--#-/gm,"'");
const worker = new Worker(Conf.DEFAULT_IEXEC_OUT);
const worker = new Worker(iexecOut);
await worker.work(query,requestID);

}catch(err){

logger.addLog("APP",JSON.stringify(err),true);
if(err instanceof Error){
logger.addLog("APP",err.toString(),true);
Expand All @@ -32,6 +40,7 @@ const _run = async ()=>{
logger.addLog("APP",err.stack,true);
}
}

}

}
Expand Down
19 changes: 2 additions & 17 deletions DApp/src/component/Worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,13 @@ export default class Worker implements IWorker {
logger: Logger;
cb?: (r: any) => void;

constructor(defualtPathOut: string | undefined) {
constructor(iexecOut:string) {
this.iexecOut=iexecOut;
this.logger =Logger.getInstance();
this.collector = new DirectoriesCollector();
//The environment IEXEC_OUT has the priority
//in order to allow the run of the DApp outside the Docker image
//(which will use the env var 'IEXEC_OUT')
//you can set the "defualtPathOut"
if (process.env.IEXEC_OUT !== undefined) {
this.iexecOut = process.env.IEXEC_OUT;
} if (defualtPathOut !== undefined) {
this.iexecOut = defualtPathOut;
} else {
this.iexecOut = "";
}
console.info = () => { };
console.debug = () => { };
console.warn = () => { };

}

err(err: string): void {
Expand All @@ -60,10 +49,6 @@ export default class Worker implements IWorker {

this.logger.setRequestID(requestID);
this.logger.addLog(componentName,"QUERY is: "+ query);

if (this.iexecOut.trim().length === 0) {
this.err("No IEXEC_OUT!");
}
//HERE WE NEED RESOLVE requestID and get
//query and directoriesList from new DSEMO-SDK
const directoriesList = await new Desmosdk().getTDDsByRequestID(requestID);
Expand Down
5 changes: 3 additions & 2 deletions DApp/tests/UseCaseTest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

import Worker from "../src/component/Worker";
import Types from "../src/const/Types";
import Conf from "../src/const/Config";

const q6 = JSON.stringify({
"prefixList": {
Expand Down Expand Up @@ -206,7 +207,7 @@ const test_05 =async ()=>{

const _test_06 =async function(cb:(ris:any) => void){
try{
const worker = new Worker(undefined);
const worker = new Worker(Conf.DEFAULT_IEXEC_OUT);
worker.setCB(cb);
await worker.work("","");
}catch(err){
Expand All @@ -229,7 +230,7 @@ const test_06 =async ()=>{

const _test_07 =async function(cb:(ris:any) => void){
try{
const worker = new Worker(undefined);
const worker = new Worker(Conf.DEFAULT_IEXEC_OUT);
worker.setCB(cb);
await worker.work("",Types.INTERNAL_TEST_REQUEST_ID_REJECT_3);
}catch(err){
Expand Down
6 changes: 1 addition & 5 deletions DApp/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,5 @@
"paths": {
"src/": ["./src/*"]
}
},
"exclude": [
"support",
"tests"
]
}
}

0 comments on commit 91d9f9a

Please sign in to comment.