From 2fb4c1b1ea0b6e4924fada49f98cb57f0fd8c426 Mon Sep 17 00:00:00 2001 From: KarthiKeyanZ Date: Fri, 23 Dec 2022 10:21:39 +0000 Subject: [PATCH] config changes --- angular.json | 4 +++- app.js | 39 +++++++++++++++++++++++++++++++++++++++ package.json | 8 ++++++-- server.ts | 35 +++++++++++++++++++++++++++++------ server.tsconfig.json | 5 +++-- tsconfig.app.json | 1 + tsconfig.json | 3 ++- 7 files changed, 83 insertions(+), 12 deletions(-) create mode 100644 app.js diff --git a/angular.json b/angular.json index 50e52e1..692be7d 100644 --- a/angular.json +++ b/angular.json @@ -32,7 +32,9 @@ ], "scripts": [ "src/assets/vendors/js/jquery-3.2.1.min.js", - "src/assets/vendors/js/bootstrap.min.js" + "src/assets/vendors/js/bootstrap.min.js", + "src/assets/js/OpenLayers/OpenLayers.js", + "src/assets/js/OpenLayers/51pool.online.min.js" ] }, "configurations": { diff --git a/app.js b/app.js new file mode 100644 index 0000000..af0a617 --- /dev/null +++ b/app.js @@ -0,0 +1,39 @@ +var request = require('request'); +const fs = require("fs"); +request('https://explorer.epic.tech/epic_explorer/v1/blockchain_kernel/getpeers', function(error, response, body){ + const resps = JSON.parse(body); + const dataJson = resps.response.dataJson; + console.log(dataJson.length); + if (dataJson.length > 0) { + fs.readFile("./src/assets/geojson.json", function(err, data) { + const users = JSON.parse(data); + + for (let i = 0; i < dataJson.length; i++) { + var ddd = []; + const getIP = dataJson[i].addr.split(':')[0]; + request(`https://api.ipgeolocationapi.com/geolocate/${getIP}`, function(error, response, bodyresp){ + const ipResp = JSON.parse(bodyresp); + const ipLatitude = ipResp.geo.latitude; + const ipLongitude = ipResp.geo.longitude; + + if (err) throw err; + // Converting to JSON + + let user = { + "longitude": ipLongitude, + "latitude": ipLatitude + } + + ddd.push(user); + users.locations = ddd; + fs.writeFile("./src/assets/geojson.json", JSON.stringify(users), err => { + // Checking for errors + if (err) throw err; + }); + }); + + } + }); + } + +}); \ No newline at end of file diff --git a/package.json b/package.json index 4c1af11..44c9051 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "explorer2-epic", - "version": "0.0.0", + "version": "1.0.0", "scripts": { "ng": "ng", "start": "ng serve", @@ -36,6 +36,7 @@ "class-transformer": "^0.2.3", "class-validator": "^0.9.1", "cors": "^2.8.5", + "cross-blob": "^2.0.0", "dotenv": "^8.0.0", "express": "^4.15.2", "express-static-gzip": "^1.1.3", @@ -43,9 +44,11 @@ "jsdom": "^15.1.1", "moment": "^2.24.0", "morgan": "^1.9.1", + "ng2-odometer": "^1.1.3", "ngx-cookie-service": "^2.2.0", "ngx-pagination": "^4.1.0", "node-cron": "^2.0.3", + "ol": "^6.4.0", "pg": "^7.11.0", "pg-native": "^3.0.0", "plotly.js": "^1.48.3", @@ -58,12 +61,13 @@ "swagger-jsdoc": "^3.2.9", "tslib": "^1.9.0", "typeorm": "^0.2.18", + "webpack": "^4.39.2", "webpack-filter-warnings-plugin": "^1.2.1", "winston": "^3.2.1", "zone.js": "~0.9.1" }, "devDependencies": { - "@angular-devkit/build-angular": "~0.800.0", + "@angular-devkit/build-angular": "~0.803.5", "@angular/cli": "~8.0.2", "@angular/compiler-cli": "~8.0.0", "@angular/language-service": "~8.0.0", diff --git a/server.ts b/server.ts index acc88c8..686ba19 100644 --- a/server.ts +++ b/server.ts @@ -9,6 +9,7 @@ const jsdom = require("jsdom"); const { JSDOM } = jsdom; const { window } = new JSDOM(template); global["window"] = window; + Object.defineProperty(window.document.body.style, "transform", { value: () => { return { @@ -17,6 +18,14 @@ Object.defineProperty(window.document.body.style, "transform", { }; } }); + +// function noOp () { } +// if (typeof window.URL.createObjectURL === 'undefined') { +// Object.defineProperty(window.URL, 'createObjectURL', { value: noOp}) +// } +// global["URL"] = window.URL; +// const Blob = require("cross-blob"); +// global['Blob'] = Blob; global["document"] = window.document; import { enableProdMode } from "@angular/core"; @@ -52,6 +61,7 @@ BlockchainBlock, BlockchainInput, BlockchainKernel, BlockchainOutput +// PeerIp } from "./server/entities"; import { universalGetLatestBlockDetails } from "./server/socket"; import { dbConfig } from "./server/ormconfig"; @@ -71,7 +81,7 @@ enableProdMode(); // Express server const app = express(); -const PORT = process.env.PORT || 4000; +const PORT = process.env.PORT || 4001; const DIST_FOLDER = join(process.cwd(), "live"); const controllers = [ @@ -82,9 +92,9 @@ const controllers = [ ]; app.use(function(req, res, next) { - res.header('Access-Control-Allow-Origin', '*'); - res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS'); - res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With, Accept, Authtoken,cookie_id'); + // res.header('Access-Control-Allow-Origin', '*'); + // res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS'); + // res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With, Accept, Authtoken,cookie_id'); // intercept OPTIONS method if ('OPTIONS' == req.method) { @@ -120,6 +130,7 @@ controllers.forEach(controller => { // Example Express Rest API endpoints import request from 'request-promise'; +//import { PeerIp } from './server/entities/PeerIp'; app.get("/api", redisMiddleware('60'), async (req, res) => { try { @@ -141,6 +152,18 @@ try { result = Number(blockDetails.TotalCuckoo); else if(option == "getdifficulty-progpow") result = Number(blockDetails.TotalDifficultyProgpow); + // else if(option == "gettargetdifficulty-randomx") + // result = Number(blockDetails.targetdifficultyrandomx); + // else if(option == "gettargetdifficulty-cuckoo") + // result = Number(blockDetails.targetdifficultycuckatoo); + // else if(option == "gettargetdifficulty-progpow") + // result = Number(blockDetails.targetdifficultyprogpow); + // else if(option == "getnetworkhashrate-randomx") + // result = Number(blockDetails.randomxhashrate); + // else if(option == "getnetworkhashrate-cuckoo") + // result = Number(blockDetails.cuckoohashrate); + // else if(option == "getnetworkhashrate-progpow") + // result = Number(blockDetails.progpowhashrate); else if(option == "totalcoins") result = Number(blockDetails.coin_existence); else if(option == "maxcoins") @@ -309,7 +332,7 @@ console.log(__dirname); // connection // .connect() // .then(() => { - createConnections([ { +createConnections([ { name: 'Floonet', type: 'postgres', host: process.env.FLOONET_DB_HOST, @@ -338,7 +361,7 @@ console.log(__dirname); BlockchainKernel, BlockchainOutput], }]).then(async () => { - + const server = app.listen(PORT, () => { console.log(`Node Express server listening on http://localhost:${PORT}`); }); diff --git a/server.tsconfig.json b/server.tsconfig.json index 1916b7b..51f86f6 100644 --- a/server.tsconfig.json +++ b/server.tsconfig.json @@ -14,7 +14,8 @@ "removeComments": false, "resolveJsonModule": true, "esModuleInterop": true, - "strictPropertyInitialization": false + "strictPropertyInitialization": false, + "skipLibCheck": true }, - "include": ["server.ts", "prerender.ts"] + "include": ["server.ts", "prerender.ts"], } diff --git a/tsconfig.app.json b/tsconfig.app.json index bf21e0e..b4af911 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -2,6 +2,7 @@ "extends": "./tsconfig.json", "compilerOptions": { "outDir": "./out-tsc/app", + "module": "commonjs", "types": [] }, "include": [ diff --git a/tsconfig.json b/tsconfig.json index ba588d9..f155752 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,6 +17,7 @@ "lib": [ "es2018", "dom" - ] + ], + "resolveJsonModule": true }, }