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", "ng": "ng",
"start": "ng serve", "start": "ng serve",
"build": "ng build", "build": "ng build",
"test": "ng test",
"lint": "ng lint", "lint": "ng lint",
"e2e": "ng e2e", "build:client-and-server-bundles": "ng build --prod && ng run explorer2-epic:server:production",
"compile:server": "webpack --config webpack.server.config.js --progress --colors", "build:prerender": "npm run build:client-and-server-bundles && npm run compile:server && npm run generate:prerender",
"serve:ssr": "node dist/server",
"build:ssr": "npm run build:client-and-server-bundles && npm run compile:server", "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, "private": true,
"dependencies": { "dependencies": {

184
server.ts
View File

@ -1,112 +1,134 @@
import 'zone.js/dist/zone-node'; import "zone.js/dist/zone-node";
import 'reflect-metadata'; import "reflect-metadata";
import {enableProdMode} from '@angular/core'; 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 // Express Engine
import {ngExpressEngine} from '@nguniversal/express-engine'; import { ngExpressEngine } from "@nguniversal/express-engine";
// Import module map for lazy loading // 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 express from "express";
import { Request, Response, NextFunction } from 'express'; import { Request, Response, NextFunction } from "express";
import * as bodyParser from 'body-parser'; import bodyParser from "body-parser";
import morgan from 'morgan'; //import { logger } from "./server/utils";
import cors from 'cors'; import swaggerJSDoc from "swagger-jsdoc";
import helmet from 'helmet'; import { errorMiddleware } from "./server/middlewares";
import * as path from 'path'; import {
import { logger } from './server/app/utils'; getRepository,
import expressStaticGzip from 'express-static-gzip'; In,
import swaggerJSDoc from 'swagger-jsdoc'; getConnection,
import { errorMiddleware } from './server/app/middlewares'; getConnectionManager
import { getRepository, In, getConnection, getConnectionManager } from 'typeorm'; } from "typeorm";
var moment = require('moment'); import { resolve } from "path";
import { resolve } from 'path'; import {
import { dbConfig } from './server/app/ormconfig'; BlockchainBlockController,
import { config } from 'dotenv'; BlockchainInputController,
// import { BlockchainKernelController,
// BlockchainBlockController, BlockchainOutputController
// BlockchainInputController, } from "./server/controllers";
// BlockchainKernelController, import { dbConfig } from "./server/ormconfig";
// BlockchainOutputController, import { config } from "dotenv";
// } from './server/app/controllers';
import { BlockchainBlockController } from './server/app/controllers/BlockchainBlock'; config({ path: resolve(__dirname, "../.env") });
import {join} from 'path';
// var controllers =
// [
// new BlockchainBlockController(),
// new BlockchainInputController(),
// new BlockchainKernelController(),
// new BlockchainOutputController(),
// ];
const connectionManager = getConnectionManager(); const connectionManager = getConnectionManager();
const connection = connectionManager.create(dbConfig); const connection = connectionManager.create(dbConfig);
import { join } from "path";
// Faster server renders w/ Prod mode (dev mode never needed) // Faster server renders w/ Prod mode (dev mode never needed)
enableProdMode(); enableProdMode();
// Express server // Express server
const app = express(); 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 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 // * 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) // Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
app.engine('html', ngExpressEngine({ app.engine(
"html",
ngExpressEngine({
bootstrap: AppServerModuleNgFactory, bootstrap: AppServerModuleNgFactory,
providers: [ providers: [provideModuleMap(LAZY_MODULE_MAP)]
provideModuleMap(LAZY_MODULE_MAP) })
] );
}));
app.set('view engine', 'html'); app.set("view engine", "html");
app.set('views', DIST_FOLDER); app.set("views", join(DIST_FOLDER, "browser"));
// 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);
// });
// Server static files from /browser // Server static files from /browser
app.get('*.*', express.static(DIST_FOLDER, { app.get(
maxAge: '1y' "*.*",
})); express.static(join(DIST_FOLDER, "browser"), {
maxAge: "1y"
})
);
// All regular routes use the Universal engine // All regular routes use the Universal engine
app.get('*', (req, res) => { app.get("*", (req, res) => {
res.render('index', { req }); res.render("index", { req });
}); });
// Start up the Node server // Start up the Node server
connection connection
.connect() .connect()
.then(() => { .then(() => {
@ -115,5 +137,5 @@ app.listen(PORT, () => {
}); });
}) })
.catch(error => { .catch(error => {
console.log('connection failed..', 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 }, where: { Hash: request.params.hash },
}); });
let paramVal = 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( var BlockchainBlockFetchQuery = await getRepository(
BlockchainBlock, BlockchainBlock,
).findOne({ ).findOne({
@ -591,9 +596,9 @@ export class BlockchainBlockController {
}); });
if (BlockchainBlockFetchQuery.EdgeBits == 29) { if (BlockchainBlockFetchQuery.EdgeBits == 29) {
BlockchainBlockFetchQuery['PoWAlgorithm'] = 'cuckARoo29'; BlockchainBlockFetchQuery['PoWAlgorithm'] = 'CuckARoo29';
} else { } else {
BlockchainBlockFetchQuery['PoWAlgorithm'] = 'cuckAToo31'; BlockchainBlockFetchQuery['PoWAlgorithm'] = 'CuckAToo31';
} }
if (BlockchainBlockFetchQuery.Height <= 1440) { if (BlockchainBlockFetchQuery.Height <= 1440) {
@ -771,8 +776,8 @@ export class BlockchainBlockController {
]) ])
.addSelect( .addSelect(
`CASE `CASE
WHEN blockchain_block.EdgeBits = 29 THEN 'cuckARoo29' WHEN blockchain_block.EdgeBits = 29 THEN 'CuckARoo29'
WHEN blockchain_block.EdgeBits = 31 THEN 'cuckARoo31' WHEN blockchain_block.EdgeBits = 31 THEN 'CuckAToo31'
END`, END`,
'PoWAlgo', 'PoWAlgo',
) )

View File

@ -1,6 +1,7 @@
import { ConnectionOptions } from 'typeorm'; import { ConnectionOptions } from 'typeorm';
import { resolve } from 'path'; import { resolve } from 'path';
import { config } from 'dotenv'; import { config } from 'dotenv';
config({ path: resolve('.env') }); config({ path: resolve('.env') });
export const dbConfig: ConnectionOptions = { 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 _layout: any;
private _options: any; private _options: any;
private _plotlyJs: 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) { @Input() set data(data: any) {
this._data = data; this._data = data;
if(this._plotlyJs){ if(this._plotlyJs){
@ -54,11 +59,9 @@ import {
); );
} }
ngAfterViewInit() { ngAfterViewInit() {
import('plotly.js/dist/plotly-cartesian.js').then(Plotly => { if(this._plotlyJs){
//stringHelpers.reverse('Hello World');
this._plotlyJs=Plotly;
this.showChart(); this.showChart();
}); }
} }
} }

View File

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

View File

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