diff --git a/package.json b/package.json index 9b648d5..bdf9306 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,11 @@ "dotenv": "^8.0.0", "express": "^4.15.2", "express-static-gzip": "^1.1.3", + "geoip-lite": "^1.4.7", "helmet": "^3.18.0", "jsdom": "^15.1.1", + "leaflet": "^1.9.4", + "leaflet.markercluster": "^1.5.3", "moment": "^2.24.0", "morgan": "^1.9.1", "ng2-odometer": "^1.1.3", diff --git a/server/controllers/BlockchainBlock.ts b/server/controllers/BlockchainBlock.ts index a4c8146..968dc11 100644 --- a/server/controllers/BlockchainBlock.ts +++ b/server/controllers/BlockchainBlock.ts @@ -26,6 +26,7 @@ import { latestBlockDetails, previousBlockDetails } from '../utils/common'; +const geoip = require('geoip-lite'); var moment = require('moment'); moment.updateLocale('en', { relativeTime: { @@ -270,6 +271,11 @@ export class BlockchainBlockController { redisMiddleware(process.env.REDIS_EXPIRY), this.getepicmineapi, ); + this.router.get( + `${this.path}/v1/peers/all`, + redisMiddleware(process.env.REDIS_EXPIRY), + this.getpeersallapi, + ); /** * @swagger @@ -758,6 +764,39 @@ export class BlockchainBlockController { console.log(error); } }; + // get /v1/peers/all + private getpeersallapi = async( request: Request,res: Response) => { + var axios = require('axios'); + try { + var config = { + method: 'get', + url: 'http://5.75.242.4:3413/v1/peers/all', + headers: { } + }; + await axios(config).then( (response) => { + const data = response.data; + + // Perform IP geolocation for each item in the 'data' array + data.forEach(peer => { + const ip = peer.addr.split(':')[0]; + const geo = geoip.lookup(ip); + + // Add the 'geo' data to the 'peer' object + peer.geo = geo; + }); + res.status(200).json({ + status: 200, + response: data + }); + }) + .catch(function (error) { + console.log('axios-error'); + console.log(error); + }); + } catch (error) { + console.log(error); + } + }; private BlockchainBlockCreate = async ( request: Request, diff --git a/src/app/shared/components/header/header.component.html b/src/app/shared/components/header/header.component.html index a68f7c1..248c3c3 100755 --- a/src/app/shared/components/header/header.component.html +++ b/src/app/shared/components/header/header.component.html @@ -56,7 +56,6 @@ -