From 1990ce1eca5a0b0aa44af913bf9c14d140f9bedd Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Tue, 15 Jun 2021 14:41:59 +0000 Subject: [PATCH] [Trunk | Explore Services] 1. extractUrlsFromSearch.ts: a. [Bug fix] In request for getting communities, resolve and reject appropriately. b. Removed require('express'), require('url'), require('cors'). c. Updated file names (date.getMonth() returns 0-11) | Add .txt in error file name. 2. package.json: Removed dependencies cors and express. 3. tsconfig.json: Added in compilerOptions: "lib": ["es2017", "dom"]. 4. svn:ignore: Ignore node_module, package-lock.json, *.xml, *.txt. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@61227 d315682c-612b-4755-9ff5-7f18f6832af3 --- services/sitempas/extractUrlsFromSearch.ts | 12 ++++-------- services/sitempas/package.json | 2 -- services/sitempas/tsconfig.json | 4 ++++ 3 files changed, 8 insertions(+), 10 deletions(-) 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 }