upgrade issuew are fixed

This commit is contained in:
sabash 2019-07-16 11:47:19 +05:30
parent a2204c6c40
commit 6ade394508
49 changed files with 1595 additions and 258 deletions

12
.env Normal file
View File

@ -0,0 +1,12 @@
# Application config
PORT = 4000
NODE_ENV = development
# DB Properties
DB_PORT = 5432
DB_HOST = localhost
DB_USERNAME = root
DB_PASSWORD = blaze.ws
DB_DATABASE = postgres

1508
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,13 +5,14 @@
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"compile:server": "webpack --config webpack.server.config.js --progress --colors",
"serve:ssr": "node dist/server",
"build:client-and-server-bundles": "ng build --prod && ng run explorer2-epic:server:production",
"build:prerender": "npm run build:client-and-server-bundles && npm run compile:server && npm run generate:prerender",
"build:ssr": "npm run build:client-and-server-bundles && npm run compile:server",
"build:client-and-server-bundles": "ng build --prod && ng run explorer2-epic:server:production"
"compile:server": "tsc -p server.tsconfig.json",
"generate:prerender": "cd dist && node prerender",
"serve:prerender": "cd dist/browser && http-server",
"serve:ssr": "node dist/server"
},
"private": true,
"dependencies": {

200
server.ts
View File

@ -1,119 +1,141 @@
import 'zone.js/dist/zone-node';
import 'reflect-metadata';
import {enableProdMode} from '@angular/core';
import "zone.js/dist/zone-node";
import "reflect-metadata";
const domino = require("domino");
const fs = require("fs");
const path = require("path");
const template = fs
.readFileSync(path.join(__dirname, ".", "browser", "index.html"))
.toString();
const win = domino.createWindow(template);
// const styleFiles = files.filter(file => file.startsWith('styles'));
// const hashStyle = styleFiles[0].split('.')[1];
// const style = fs.readFileSync(path.join(__dirname, '.', 'dist-server', `styles.${hashStyle}.bundle.css`)).toString();
global["window"] = win;
Object.defineProperty(win.document.body.style, "transform", {
value: () => {
return {
enumerable: true,
configurable: true
};
}
});
global["document"] = win.document;
// global["CSS"] = win;
// global['XMLHttpRequest'] = require('xmlhttprequest').XMLHttpRequest;
// global["Prism"] = null;
import { enableProdMode } from "@angular/core";
// Express Engine
import {ngExpressEngine} from '@nguniversal/express-engine';
import { ngExpressEngine } from "@nguniversal/express-engine";
// Import module map for lazy loading
import {provideModuleMap} from '@nguniversal/module-map-ngfactory-loader';
import { provideModuleMap } from "@nguniversal/module-map-ngfactory-loader";
import * as express from 'express';
import { Request, Response, NextFunction } from 'express';
import * as bodyParser from 'body-parser';
import morgan from 'morgan';
import cors from 'cors';
import helmet from 'helmet';
import * as path from 'path';
import { logger } from './server/app/utils';
import expressStaticGzip from 'express-static-gzip';
import swaggerJSDoc from 'swagger-jsdoc';
import { errorMiddleware } from './server/app/middlewares';
import { getRepository, In, getConnection, getConnectionManager } from 'typeorm';
var moment = require('moment');
import { resolve } from 'path';
import { dbConfig } from './server/app/ormconfig';
import { config } from 'dotenv';
// import {
// BlockchainBlockController,
// BlockchainInputController,
// BlockchainKernelController,
// BlockchainOutputController,
// } from './server/app/controllers';
import express from "express";
import { Request, Response, NextFunction } from "express";
import bodyParser from "body-parser";
//import { logger } from "./server/utils";
import swaggerJSDoc from "swagger-jsdoc";
import { errorMiddleware } from "./server/middlewares";
import {
getRepository,
In,
getConnection,
getConnectionManager
} from "typeorm";
import { resolve } from "path";
import {
BlockchainBlockController,
BlockchainInputController,
BlockchainKernelController,
BlockchainOutputController
} from "./server/controllers";
import { dbConfig } from "./server/ormconfig";
import { config } from "dotenv";
import { BlockchainBlockController } from './server/app/controllers/BlockchainBlock';
config({ path: resolve(__dirname, "../.env") });
import {join} from 'path';
const connectionManager = getConnectionManager();
const connection = connectionManager.create(dbConfig);
// var controllers =
// [
// new BlockchainBlockController(),
// new BlockchainInputController(),
// new BlockchainKernelController(),
// new BlockchainOutputController(),
// ];
const connectionManager = getConnectionManager();
const connection = connectionManager.create(dbConfig);
import { join } from "path";
// Faster server renders w/ Prod mode (dev mode never needed)
enableProdMode();
// Express server
const app = express();
let controllerblockchain = new BlockchainBlockController();
app.use(helmet());
app.use(cors());
app.use(morgan('combined'));
app.use(bodyParser.json({ limit: '50mb' }));
app.use(bodyParser.urlencoded({ extended: false }));
app.use('/api-docs', express.static(path.join(__dirname, 'swagger')));
app.get('/swagger.json', function(req, res) {
res.setHeader('Content-Type', 'application/json');
res.send(
swaggerJSDoc({
swaggerDefinition: require('./server/app/swagger/swagger.json'),
apis: ['**/*.ts'],
}),
);
});
app.use(errorMiddleware);
const PORT = process.env.PORT || 4000;
const DIST_FOLDER = join(process.cwd(), 'dist/browser');
const DIST_FOLDER = join(process.cwd(), "dist");
const controllers = [
new BlockchainBlockController(),
new BlockchainInputController(),
new BlockchainKernelController(),
new BlockchainOutputController()
];
app.use(errorMiddleware);
app.use(bodyParser.json({ limit: "50mb" }));
app.use(bodyParser.urlencoded({ extended: false }));
app.use("/api-docs/**", express.static(path.join(__dirname, "./server/swagger")));
app.get("/swagger.json", function(req, res) {
res.setHeader("Content-Type", "application/json");
res.send(
swaggerJSDoc({
swaggerDefinition: require("./swagger/swagger.json"),
apis: ["**/*.ts"]
})
);
});
controllers.forEach(controller => {
app.use("/epic_explorer/v1", controller.router);
});
// Example Express Rest API endpoints
app.get('/epic_explorer/v1/**', (req, res) => { res.send({'msg':'Api works.'})});
// * NOTE :: leave this as require() since this file is built Dynamically from webpack
const {AppServerModuleNgFactory, LAZY_MODULE_MAP} = require('./dist/server/main');
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require("./server/main");
// Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
app.engine('html', ngExpressEngine({
bootstrap: AppServerModuleNgFactory,
providers: [
provideModuleMap(LAZY_MODULE_MAP)
]
}));
app.engine(
"html",
ngExpressEngine({
bootstrap: AppServerModuleNgFactory,
providers: [provideModuleMap(LAZY_MODULE_MAP)]
})
);
app.set('view engine', 'html');
app.set('views', DIST_FOLDER);
// Example Express Rest API endpoints
app.get('/api/test/ok', (req, res) => {
res.status(200).json({
status: 200,
message: 'perifsdfsfod of blocks generation per second fetched Successfully',
});
});
// controllers.forEach(controller => {
// app.use('/epic_explorer/v1', controller.router);
// });
app.set("view engine", "html");
app.set("views", join(DIST_FOLDER, "browser"));
// Server static files from /browser
app.get('*.*', express.static(DIST_FOLDER, {
maxAge: '1y'
}));
app.get(
"*.*",
express.static(join(DIST_FOLDER, "browser"), {
maxAge: "1y"
})
);
// All regular routes use the Universal engine
app.get('*', (req, res) => {
res.render('index', { req });
app.get("*", (req, res) => {
res.render("index", { req });
});
// Start up the Node server
connection
.connect()
.then(() => {
app.listen(PORT, () => {
console.log(`Node Express server listening on http://localhost:${PORT}`);
});
})
.catch(error => {
console.log('connection failed..', error);
});
app.listen(PORT, () => {
console.log(`Node Express server listening on http://localhost:${PORT}`);
});
})
.catch(error => {
console.log("connection failed..", error);
});

20
server.tsconfig.json Normal file
View File

@ -0,0 +1,20 @@
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist",
"sourceMap": true,
"declaration": true,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"typeRoots": ["node_modules/@types"],
"lib": ["es2017", "dom"],
"module": "commonjs",
"removeComments": false,
"resolveJsonModule": true,
"esModuleInterop": true,
"strictPropertyInitialization": false
},
"include": ["server.ts", "prerender.ts"]
}

View File

@ -1,31 +0,0 @@
import * as winston from 'winston';
export function logger() {
return winston.createLogger({
transports: [
new winston.transports.File({
level: 'info',
filename: './log/all-logs.log',
handleExceptions: true,
maxsize: 5242880, //5MB
maxFiles: 5,
}),
new winston.transports.Console({
format: winston.format.combine(
winston.format.colorize(),
winston.format.timestamp(),
winston.format.align(),
winston.format.printf(info => {
const { timestamp, level, message, ...args } = info;
const ts = timestamp.slice(0, 19).replace('T', ' ');
return `${ts} [${level}]: ${message} ${
Object.keys(args).length ? JSON.stringify(args, null, 2) : ''
}`;
}),
),
}),
],
exitOnError: false,
});
}

View File

@ -549,7 +549,12 @@ export class BlockchainBlockController {
where: { Hash: request.params.hash },
});
let paramVal = request.params.hash;
if (!BlockchainBlockFetchQuery && !isNaN(paramVal)) {
if (
!BlockchainBlockFetchQuery &&
!isNaN(paramVal) &&
paramVal.length <= 10 &&
paramVal <= 2147483647
) {
var BlockchainBlockFetchQuery = await getRepository(
BlockchainBlock,
).findOne({
@ -591,9 +596,9 @@ export class BlockchainBlockController {
});
if (BlockchainBlockFetchQuery.EdgeBits == 29) {
BlockchainBlockFetchQuery['PoWAlgorithm'] = 'cuckARoo29';
BlockchainBlockFetchQuery['PoWAlgorithm'] = 'CuckARoo29';
} else {
BlockchainBlockFetchQuery['PoWAlgorithm'] = 'cuckAToo31';
BlockchainBlockFetchQuery['PoWAlgorithm'] = 'CuckAToo31';
}
if (BlockchainBlockFetchQuery.Height <= 1440) {
@ -771,8 +776,8 @@ export class BlockchainBlockController {
])
.addSelect(
`CASE
WHEN blockchain_block.EdgeBits = 29 THEN 'cuckARoo29'
WHEN blockchain_block.EdgeBits = 31 THEN 'cuckARoo31'
WHEN blockchain_block.EdgeBits = 29 THEN 'CuckARoo29'
WHEN blockchain_block.EdgeBits = 31 THEN 'CuckAToo31'
END`,
'PoWAlgo',
)

View File

@ -1,6 +1,7 @@
import { ConnectionOptions } from 'typeorm';
import { resolve } from 'path';
import { config } from 'dotenv';
config({ path: resolve('.env') });
export const dbConfig: ConnectionOptions = {

View File

Before

Width:  |  Height:  |  Size: 665 B

After

Width:  |  Height:  |  Size: 665 B

View File

Before

Width:  |  Height:  |  Size: 628 B

After

Width:  |  Height:  |  Size: 628 B

32
server/utils/logger.ts Normal file
View File

@ -0,0 +1,32 @@
//import winston from 'winston';
export function logger() {
// return winston.createLogger({
// transports: [
// new winston.transports.File({
// level: 'info',
// filename: './log/all-logs.log',
// handleExceptions: true,
// maxsize: 5242880, //5MB
// maxFiles: 5,
// }),
// new winston.transports.Console({
// format: winston.format.combine(
// winston.format.colorize(),
// winston.format.timestamp(),
// winston.format.align(),
// winston.format.printf(info => {
// const { timestamp, level, message, ...args } = info;
// const ts = timestamp.slice(0, 19).replace('T', ' ');
// return `${ts} [${level}]: ${message} ${
// Object.keys(args).length ? JSON.stringify(args, null, 2) : ''
// }`;
// }),
// ),
// }),
// ],
// exitOnError: false,
// });
return true;
}

View File

@ -18,8 +18,13 @@ import {
private _layout: any;
private _options: any;
private _plotlyJs: any;
constructor() { }
constructor() {
import('plotly.js/dist/plotly-cartesian.js').then(Plotly => {
//stringHelpers.reverse('Hello World');
this._plotlyJs=Plotly;
this.showChart();
});
}
@Input() set data(data: any) {
this._data = data;
if(this._plotlyJs){
@ -54,11 +59,9 @@ import {
);
}
ngAfterViewInit() {
import('plotly.js/dist/plotly-cartesian.js').then(Plotly => {
//stringHelpers.reverse('Hello World');
this._plotlyJs=Plotly;
if(this._plotlyJs){
this.showChart();
});
}
}
}

View File

@ -1,5 +1,5 @@
export const environment = {
production: true,
domain: 'http://explorer2.epic.tech/',
apiUrl: 'http://explorer2.epic.tech/epic_explorer/v1',
domain: '/',
apiUrl: '/epic_explorer/v1',
};

View File

@ -4,8 +4,8 @@
export const environment = {
production: false,
domain: 'http://explorer2.epic.tech/',
apiUrl: 'http://explorer2.epic.tech/epic_explorer/v1',
domain: '/',
apiUrl: '/epic_explorer/v1',
};
/*