diff --git a/services/sitempas/extractUrlsFromSearch.ts b/services/sitempas/extractUrlsFromSearch.ts index 48186923..760cae49 100644 --- a/services/sitempas/extractUrlsFromSearch.ts +++ b/services/sitempas/extractUrlsFromSearch.ts @@ -8,12 +8,7 @@ import {Identifier} from "../../explore/src/app/openaireLibrary/utils/string-uti import {SearchFields} from "../../explore/src/app/openaireLibrary/utils/properties/searchFields"; import {ContextsService} from "../../explore/src/app/openaireLibrary/claims/claim-utils/service/contexts.service"; -let express = require('express'); -let app = express(); const request = require('superagent'); -const URL = require('url'); -let cors = require('cors'); -app.use(cors()); function get(resultsPerUrl) { setTimeout(() => { @@ -208,13 +203,14 @@ function getUrlByType(type: any, pid: any, id: any) { function getCommunities() { communitiesPromise = new Promise((resolve, reject) => { - resolve(); request.get(contextUrl, async function (err: any, communitiesResponse: any) { if (!communitiesResponse && err) { console.error("Error getting communities ", err); + reject(); } else { const contextsService = new ContextsService(); publicCommunities = contextsService.parseCommunities(communitiesResponse.body, false).map(value => value.id); + resolve(); } }) }); @@ -224,8 +220,8 @@ function buildSiteMap(resultsPerUrl) { console.time("total_time"); let date = new Date(); - fileName = "sitemap_"+date.getFullYear()+"_"+date.getMonth()+"_"+date.getDate()+".xml";//+"_"+date.getTime(); - errorFileName = "error_"+date.getFullYear()+"_"+date.getMonth()+"_"+date.getDate();//+"_"+date.getTime(); + fileName = "sitemap_"+date.getFullYear()+"_"+(date.getMonth()+1)+"_"+date.getDate()+".xml";//+"_"+date.getTime(); + errorFileName = "error_"+date.getFullYear()+"_"+(date.getMonth()+1)+"_"+date.getDate()+".txt";//+"_"+date.getTime(); console.log("Buiding sitemap in file: "+fileName+"\n"); let sitemap = "\n" + diff --git a/services/sitempas/package.json b/services/sitempas/package.json index 705892e0..7ca9a467 100644 --- a/services/sitempas/package.json +++ b/services/sitempas/package.json @@ -7,8 +7,6 @@ "start": "PORT=3100 node extractUrlsFromSearch.js" }, "dependencies": { - "cors": "^2.8.5", - "express": "^4.17.1", "superagent": "^5.0.5" }, "devDependencies": { diff --git a/services/sitempas/tsconfig.json b/services/sitempas/tsconfig.json index ff2d82a7..05dba857 100644 --- a/services/sitempas/tsconfig.json +++ b/services/sitempas/tsconfig.json @@ -4,6 +4,10 @@ "node_modules/@types" ], "noImplicitAny": false, + "lib": [ + "es2017", + "dom" + ], "emitDecoratorMetadata": true, "experimentalDecorators": true }