reddish cache integration
This commit is contained in:
parent
e675be14b5
commit
045636da98
12
.env
12
.env
@ -7,18 +7,20 @@ NODE_ENV = development
|
|||||||
|
|
||||||
TESTNET_DB_PORT = 5432
|
TESTNET_DB_PORT = 5432
|
||||||
TESTNET_DB_HOST = localhost
|
TESTNET_DB_HOST = localhost
|
||||||
TESTNET_DB_USERNAME = root
|
TESTNET_DB_USERNAME = postgres
|
||||||
TESTNET_DB_PASSWORD = blaze.ws
|
TESTNET_DB_PASSWORD = blaze.ws
|
||||||
TESTNET_DB_DATABASE = epic_data_new
|
TESTNET_DB_DATABASE = epicnew
|
||||||
|
|
||||||
|
|
||||||
FLOONET_DB_PORT = 5432
|
FLOONET_DB_PORT = 5432
|
||||||
FLOONET_DB_HOST = localhost
|
FLOONET_DB_HOST = localhost
|
||||||
FLOONET_DB_USERNAME = root
|
FLOONET_DB_USERNAME = postgres
|
||||||
FLOONET_DB_PASSWORD = blaze.ws
|
FLOONET_DB_PASSWORD = blaze.ws
|
||||||
FLOONET_DB_DATABASE = epic
|
FLOONET_DB_DATABASE = epicnew
|
||||||
|
|
||||||
TESTNET_PEER_URL = http://116.203.152.58:3413/v1/peers/connected
|
TESTNET_PEER_URL = http://116.203.152.58:3413/v1/peers/connected
|
||||||
FLOONET_PEER_URL = http://116.203.152.58:13413/v1/peers/connected
|
FLOONET_PEER_URL = http://116.203.152.58:13413/v1/peers/connected
|
||||||
|
|
||||||
TIME_ZONE = utc
|
TIME_ZONE = utc
|
||||||
|
|
||||||
|
REDIS_KEY = explorer2
|
||||||
|
REDIS_EXPIRY = 60
|
@ -6,7 +6,7 @@
|
|||||||
"start": "ng serve",
|
"start": "ng serve",
|
||||||
"build": "ng build",
|
"build": "ng build",
|
||||||
"lint": "ng lint",
|
"lint": "ng lint",
|
||||||
"copyToLive":"rm -rf live && cp -rf dist live",
|
"copyToLive": "rm -rf live && cp -rf dist live",
|
||||||
"build:client-and-server-bundles": "ng build --prod && ng run explorer2-epic:server:production",
|
"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: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 && npm run move:build && npm run copyToLive",
|
"build:ssr": "npm run build:client-and-server-bundles && npm run compile:server && npm run move:build && npm run copyToLive",
|
||||||
@ -30,6 +30,7 @@
|
|||||||
"@nguniversal/express-engine": "^7.0.2",
|
"@nguniversal/express-engine": "^7.0.2",
|
||||||
"@nguniversal/module-map-ngfactory-loader": "^7.0.2",
|
"@nguniversal/module-map-ngfactory-loader": "^7.0.2",
|
||||||
"@ngx-translate/core": "^11.0.1",
|
"@ngx-translate/core": "^11.0.1",
|
||||||
|
"axios": "^0.19.0",
|
||||||
"babel-preset-es2015": "^6.24.1",
|
"babel-preset-es2015": "^6.24.1",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"class-transformer": "^0.2.3",
|
"class-transformer": "^0.2.3",
|
||||||
@ -46,6 +47,7 @@
|
|||||||
"pg": "^7.11.0",
|
"pg": "^7.11.0",
|
||||||
"pg-native": "^3.0.0",
|
"pg-native": "^3.0.0",
|
||||||
"plotly.js": "^1.48.3",
|
"plotly.js": "^1.48.3",
|
||||||
|
"redis": "^2.8.0",
|
||||||
"rxjs": "~6.4.0",
|
"rxjs": "~6.4.0",
|
||||||
"socket.io": "^2.2.0",
|
"socket.io": "^2.2.0",
|
||||||
"socket.io-client": "^2.2.0",
|
"socket.io-client": "^2.2.0",
|
||||||
@ -61,9 +63,11 @@
|
|||||||
"@angular/cli": "~8.0.2",
|
"@angular/cli": "~8.0.2",
|
||||||
"@angular/compiler-cli": "~8.0.0",
|
"@angular/compiler-cli": "~8.0.0",
|
||||||
"@angular/language-service": "~8.0.0",
|
"@angular/language-service": "~8.0.0",
|
||||||
"@types/node": "~8.9.4",
|
|
||||||
"@types/jasmine": "~3.3.8",
|
"@types/jasmine": "~3.3.8",
|
||||||
"@types/jasminewd2": "~2.0.3",
|
"@types/jasminewd2": "~2.0.3",
|
||||||
|
"@types/memory-cache": "^0.2.0",
|
||||||
|
"@types/node": "~8.9.4",
|
||||||
|
"@types/redis": "^2.8.13",
|
||||||
"codelyzer": "^5.0.0",
|
"codelyzer": "^5.0.0",
|
||||||
"jasmine-core": "~3.4.0",
|
"jasmine-core": "~3.4.0",
|
||||||
"jasmine-spec-reporter": "~4.2.1",
|
"jasmine-spec-reporter": "~4.2.1",
|
||||||
|
@ -2,7 +2,7 @@ import express from 'express';
|
|||||||
import { Global } from "../global";
|
import { Global } from "../global";
|
||||||
import { Request, Response, NextFunction } from 'express';
|
import { Request, Response, NextFunction } from 'express';
|
||||||
import { getRepository, getConnection } from 'typeorm';
|
import { getRepository, getConnection } from 'typeorm';
|
||||||
import { validationMiddleware } from '../middlewares';
|
import { validationMiddleware, redisMiddleware } from '../middlewares';
|
||||||
import {
|
import {
|
||||||
InternalServerErrorException,
|
InternalServerErrorException,
|
||||||
NoDataFoundException,
|
NoDataFoundException,
|
||||||
@ -208,6 +208,7 @@ export class BlockchainBlockController {
|
|||||||
this.router.post(
|
this.router.post(
|
||||||
`${this.path}`,
|
`${this.path}`,
|
||||||
validationMiddleware(BlockchainBlockCreateDto),
|
validationMiddleware(BlockchainBlockCreateDto),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockchainBlockCreate,
|
this.BlockchainBlockCreate,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -251,6 +252,7 @@ export class BlockchainBlockController {
|
|||||||
this.router.get(
|
this.router.get(
|
||||||
`${this.path}/totaldiff`,
|
`${this.path}/totaldiff`,
|
||||||
validationMiddleware(TotalDifficultyNBlockDto, true),
|
validationMiddleware(TotalDifficultyNBlockDto, true),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.TotalDifficultyNBlock,
|
this.TotalDifficultyNBlock,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -286,6 +288,7 @@ export class BlockchainBlockController {
|
|||||||
this.router.get(
|
this.router.get(
|
||||||
`${this.path}/blockcount`,
|
`${this.path}/blockcount`,
|
||||||
validationMiddleware(TotalDifficultyNBlockDto, true),
|
validationMiddleware(TotalDifficultyNBlockDto, true),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockCount,
|
this.BlockCount,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -315,6 +318,7 @@ export class BlockchainBlockController {
|
|||||||
this.router.get(
|
this.router.get(
|
||||||
`${this.path}/blockinterval`,
|
`${this.path}/blockinterval`,
|
||||||
validationMiddleware(TotalDifficultyNBlockDto, true),
|
validationMiddleware(TotalDifficultyNBlockDto, true),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockInterval,
|
this.BlockInterval,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -350,6 +354,7 @@ export class BlockchainBlockController {
|
|||||||
this.router.get(
|
this.router.get(
|
||||||
`${this.path}/stackblock`,
|
`${this.path}/stackblock`,
|
||||||
validationMiddleware(TotalDifficultyNBlockDto, true),
|
validationMiddleware(TotalDifficultyNBlockDto, true),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.StackBlock,
|
this.StackBlock,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -385,6 +390,7 @@ export class BlockchainBlockController {
|
|||||||
this.router.get(
|
this.router.get(
|
||||||
`${this.path}/blockpiechart`,
|
`${this.path}/blockpiechart`,
|
||||||
validationMiddleware(TotalDifficultyNBlockDto, true),
|
validationMiddleware(TotalDifficultyNBlockDto, true),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockPieChart,
|
this.BlockPieChart,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -420,6 +426,7 @@ export class BlockchainBlockController {
|
|||||||
this.router.get(
|
this.router.get(
|
||||||
`${this.path}/hashrate`,
|
`${this.path}/hashrate`,
|
||||||
validationMiddleware(TotalDifficultyNBlockDto, true),
|
validationMiddleware(TotalDifficultyNBlockDto, true),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.HashRate,
|
this.HashRate,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -442,6 +449,7 @@ export class BlockchainBlockController {
|
|||||||
this.router.get(
|
this.router.get(
|
||||||
`${this.path}/latesblockdetails`,
|
`${this.path}/latesblockdetails`,
|
||||||
validationMiddleware(TotalDifficultyNBlockDto, true),
|
validationMiddleware(TotalDifficultyNBlockDto, true),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.LatestDifficultyNBlock,
|
this.LatestDifficultyNBlock,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -477,6 +485,7 @@ export class BlockchainBlockController {
|
|||||||
this.router.get(
|
this.router.get(
|
||||||
`${this.path}/blockspersec`,
|
`${this.path}/blockspersec`,
|
||||||
validationMiddleware(TotalDifficultyNBlockDto, true),
|
validationMiddleware(TotalDifficultyNBlockDto, true),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockchainBlockPerSecond,
|
this.BlockchainBlockPerSecond,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -512,6 +521,7 @@ export class BlockchainBlockController {
|
|||||||
this.router.get(
|
this.router.get(
|
||||||
`${this.path}/supplygrowth`,
|
`${this.path}/supplygrowth`,
|
||||||
validationMiddleware(TotalDifficultyNBlockDto, true),
|
validationMiddleware(TotalDifficultyNBlockDto, true),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.SupplyGrowth,
|
this.SupplyGrowth,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -547,6 +557,7 @@ export class BlockchainBlockController {
|
|||||||
this.router.get(
|
this.router.get(
|
||||||
`${this.path}/blockminedchart`,
|
`${this.path}/blockminedchart`,
|
||||||
validationMiddleware(TotalDifficultyNBlockDto, true),
|
validationMiddleware(TotalDifficultyNBlockDto, true),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockMineChart,
|
this.BlockMineChart,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -580,6 +591,7 @@ export class BlockchainBlockController {
|
|||||||
this.router.get(
|
this.router.get(
|
||||||
`${this.path}/list`,
|
`${this.path}/list`,
|
||||||
validationMiddleware(BlockchainBlockPaginationDto),
|
validationMiddleware(BlockchainBlockPaginationDto),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockchainBlockPagination,
|
this.BlockchainBlockPagination,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -608,6 +620,7 @@ export class BlockchainBlockController {
|
|||||||
this.router.get(
|
this.router.get(
|
||||||
`${this.path}/:hash`,
|
`${this.path}/:hash`,
|
||||||
validationMiddleware(BlockchainBlockSingleViewDto, true),
|
validationMiddleware(BlockchainBlockSingleViewDto, true),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockchainBlockFetch,
|
this.BlockchainBlockFetch,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -637,6 +650,7 @@ export class BlockchainBlockController {
|
|||||||
this.router.patch(
|
this.router.patch(
|
||||||
`${this.path}`,
|
`${this.path}`,
|
||||||
validationMiddleware(BlockchainBlockUpdateDto),
|
validationMiddleware(BlockchainBlockUpdateDto),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockchainBlockUpdate,
|
this.BlockchainBlockUpdate,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -665,6 +679,7 @@ export class BlockchainBlockController {
|
|||||||
this.router.delete(
|
this.router.delete(
|
||||||
`${this.path}/:hash`,
|
`${this.path}/:hash`,
|
||||||
validationMiddleware(BlockchainBlockSingleViewDto),
|
validationMiddleware(BlockchainBlockSingleViewDto),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockchainBlockDelete,
|
this.BlockchainBlockDelete,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { Request, Response, NextFunction } from 'express';
|
import { Request, Response, NextFunction } from 'express';
|
||||||
import { getRepository,getConnection } from 'typeorm';
|
import { getRepository,getConnection } from 'typeorm';
|
||||||
import { validationMiddleware } from '../middlewares';
|
import { validationMiddleware, redisMiddleware } from '../middlewares';
|
||||||
import {
|
import {
|
||||||
InternalServerErrorException,
|
InternalServerErrorException,
|
||||||
NoDataFoundException,
|
NoDataFoundException,
|
||||||
@ -63,6 +63,7 @@ export class BlockchainInputController {
|
|||||||
this.router.post(
|
this.router.post(
|
||||||
`${this.path}`,
|
`${this.path}`,
|
||||||
validationMiddleware(BlockchainInputCreateDto),
|
validationMiddleware(BlockchainInputCreateDto),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockchainInputCreate,
|
this.BlockchainInputCreate,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -101,6 +102,7 @@ export class BlockchainInputController {
|
|||||||
this.router.get(
|
this.router.get(
|
||||||
`${this.path}/list`,
|
`${this.path}/list`,
|
||||||
validationMiddleware(BlockchainInputPaginationDto),
|
validationMiddleware(BlockchainInputPaginationDto),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockchainInputPagination,
|
this.BlockchainInputPagination,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -129,6 +131,7 @@ export class BlockchainInputController {
|
|||||||
this.router.get(
|
this.router.get(
|
||||||
`${this.path}/:id`,
|
`${this.path}/:id`,
|
||||||
validationMiddleware(BlockchainInputSingleViewDto),
|
validationMiddleware(BlockchainInputSingleViewDto),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockchainInputFetch,
|
this.BlockchainInputFetch,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -158,6 +161,7 @@ export class BlockchainInputController {
|
|||||||
this.router.patch(
|
this.router.patch(
|
||||||
`${this.path}`,
|
`${this.path}`,
|
||||||
validationMiddleware(BlockchainInputUpdateDto),
|
validationMiddleware(BlockchainInputUpdateDto),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockchainInputUpdate,
|
this.BlockchainInputUpdate,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -186,6 +190,7 @@ export class BlockchainInputController {
|
|||||||
this.router.delete(
|
this.router.delete(
|
||||||
`${this.path}/:id`,
|
`${this.path}/:id`,
|
||||||
validationMiddleware(BlockchainInputSingleViewDto),
|
validationMiddleware(BlockchainInputSingleViewDto),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockchainInputDelete,
|
this.BlockchainInputDelete,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { Request, Response, NextFunction } from 'express';
|
import { Request, Response, NextFunction } from 'express';
|
||||||
import { getRepository, getConnection } from 'typeorm';
|
import { getRepository, getConnection } from 'typeorm';
|
||||||
import { validationMiddleware } from '../middlewares';
|
import { validationMiddleware, redisMiddleware } from '../middlewares';
|
||||||
import { Global } from "../global";
|
import { Global } from "../global";
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import {
|
import {
|
||||||
@ -84,6 +84,7 @@ export class BlockchainKernelController {
|
|||||||
this.router.post(
|
this.router.post(
|
||||||
`${this.path}`,
|
`${this.path}`,
|
||||||
validationMiddleware(BlockchainKernelCreateDto),
|
validationMiddleware(BlockchainKernelCreateDto),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockchainKernelCreate,
|
this.BlockchainKernelCreate,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -119,6 +120,7 @@ export class BlockchainKernelController {
|
|||||||
this.router.get(
|
this.router.get(
|
||||||
`${this.path}/transactionfee`,
|
`${this.path}/transactionfee`,
|
||||||
validationMiddleware(TransactionFeeDto, true),
|
validationMiddleware(TransactionFeeDto, true),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.TransactionFee,
|
this.TransactionFee,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -211,6 +213,7 @@ export class BlockchainKernelController {
|
|||||||
this.router.get(
|
this.router.get(
|
||||||
`${this.path}/transactionheatmap`,
|
`${this.path}/transactionheatmap`,
|
||||||
validationMiddleware(TransactionFeeDto, true),
|
validationMiddleware(TransactionFeeDto, true),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.HeatmapChart,
|
this.HeatmapChart,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -246,6 +249,7 @@ export class BlockchainKernelController {
|
|||||||
this.router.get(
|
this.router.get(
|
||||||
`${this.path}/transactionlinechart`,
|
`${this.path}/transactionlinechart`,
|
||||||
validationMiddleware(TransactionFeeDto, true),
|
validationMiddleware(TransactionFeeDto, true),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.TransactionChart,
|
this.TransactionChart,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -284,6 +288,7 @@ export class BlockchainKernelController {
|
|||||||
this.router.get(
|
this.router.get(
|
||||||
`${this.path}/list`,
|
`${this.path}/list`,
|
||||||
validationMiddleware(BlockchainKernelPaginationDto),
|
validationMiddleware(BlockchainKernelPaginationDto),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockchainKernelPagination,
|
this.BlockchainKernelPagination,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -312,6 +317,7 @@ export class BlockchainKernelController {
|
|||||||
this.router.get(
|
this.router.get(
|
||||||
`${this.path}/:id`,
|
`${this.path}/:id`,
|
||||||
validationMiddleware(BlockchainKernelSingleViewDto),
|
validationMiddleware(BlockchainKernelSingleViewDto),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockchainKernelFetch,
|
this.BlockchainKernelFetch,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -341,6 +347,7 @@ export class BlockchainKernelController {
|
|||||||
this.router.patch(
|
this.router.patch(
|
||||||
`${this.path}`,
|
`${this.path}`,
|
||||||
validationMiddleware(BlockchainKernelUpdateDto),
|
validationMiddleware(BlockchainKernelUpdateDto),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockchainKernelUpdate,
|
this.BlockchainKernelUpdate,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -369,6 +376,7 @@ export class BlockchainKernelController {
|
|||||||
this.router.delete(
|
this.router.delete(
|
||||||
`${this.path}/:id`,
|
`${this.path}/:id`,
|
||||||
validationMiddleware(BlockchainKernelSingleViewDto),
|
validationMiddleware(BlockchainKernelSingleViewDto),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockchainKernelDelete,
|
this.BlockchainKernelDelete,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { Request, Response, NextFunction } from 'express';
|
import { Request, Response, NextFunction } from 'express';
|
||||||
import { getRepository, getConnection } from 'typeorm';
|
import { getRepository, getConnection } from 'typeorm';
|
||||||
import { validationMiddleware } from '../middlewares';
|
import { validationMiddleware, redisMiddleware } from '../middlewares';
|
||||||
import { Global } from "../global";
|
import { Global } from "../global";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -77,6 +77,7 @@ export class BlockchainOutputController {
|
|||||||
this.router.post(
|
this.router.post(
|
||||||
`${this.path}`,
|
`${this.path}`,
|
||||||
validationMiddleware(BlockchainOutputCreateDto),
|
validationMiddleware(BlockchainOutputCreateDto),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockchainOutputCreate,
|
this.BlockchainOutputCreate,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -115,6 +116,7 @@ export class BlockchainOutputController {
|
|||||||
this.router.get(
|
this.router.get(
|
||||||
`${this.path}/list`,
|
`${this.path}/list`,
|
||||||
validationMiddleware(BlockchainOutputPaginationDto),
|
validationMiddleware(BlockchainOutputPaginationDto),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockchainOutputPagination,
|
this.BlockchainOutputPagination,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -143,6 +145,7 @@ export class BlockchainOutputController {
|
|||||||
this.router.get(
|
this.router.get(
|
||||||
`${this.path}/:id`,
|
`${this.path}/:id`,
|
||||||
validationMiddleware(BlockchainOutputSingleViewDto),
|
validationMiddleware(BlockchainOutputSingleViewDto),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockchainOutputFetch,
|
this.BlockchainOutputFetch,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -172,6 +175,7 @@ export class BlockchainOutputController {
|
|||||||
this.router.patch(
|
this.router.patch(
|
||||||
`${this.path}`,
|
`${this.path}`,
|
||||||
validationMiddleware(BlockchainOutputUpdateDto),
|
validationMiddleware(BlockchainOutputUpdateDto),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockchainOutputUpdate,
|
this.BlockchainOutputUpdate,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -200,6 +204,7 @@ export class BlockchainOutputController {
|
|||||||
this.router.delete(
|
this.router.delete(
|
||||||
`${this.path}/:id`,
|
`${this.path}/:id`,
|
||||||
validationMiddleware(BlockchainOutputSingleViewDto),
|
validationMiddleware(BlockchainOutputSingleViewDto),
|
||||||
|
redisMiddleware(process.env.REDIS_EXPIRY),
|
||||||
this.BlockchainOutputDelete,
|
this.BlockchainOutputDelete,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
export * from './error.middleware';
|
export * from './error.middleware';
|
||||||
export * from './validator.middleware';
|
export * from './validator.middleware';
|
||||||
|
export * from './redis.middleware';
|
45
server/middlewares/redis.middleware.ts
Normal file
45
server/middlewares/redis.middleware.ts
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import { NextFunction, Request, Response } from 'express';
|
||||||
|
import { HttpException } from '../exceptions/index';
|
||||||
|
import * as redis from 'redis';
|
||||||
|
import { Global } from "../global";
|
||||||
|
import { Duration } from 'moment';
|
||||||
|
|
||||||
|
// connect to Redis
|
||||||
|
const REDIS_URL = process.env.REDIS_URL;
|
||||||
|
const client = redis.createClient(REDIS_URL);
|
||||||
|
|
||||||
|
client.on('connect', () => {
|
||||||
|
console.log(`connected to redis`);
|
||||||
|
});
|
||||||
|
client.on('error', err => {
|
||||||
|
console.log(`Error: ${err}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
export function redisMiddleware(
|
||||||
|
duration: any,
|
||||||
|
) {
|
||||||
|
console.log(duration);
|
||||||
|
return (request, response, next) => {
|
||||||
|
// Global.network = request.headers.network;
|
||||||
|
let key = process.env.REDIS_KEY + Global.network + request.originalUrl || request.url
|
||||||
|
client.get(key, function(err, reply){
|
||||||
|
if(reply && duration!=0){
|
||||||
|
console.log("key : ", key);
|
||||||
|
console.log("reply : ", reply);
|
||||||
|
console.log("---------------------------------------------------------------------------------------");
|
||||||
|
console.log(`enabled`);
|
||||||
|
response.send(reply);
|
||||||
|
}else{
|
||||||
|
console.log(`raw`);
|
||||||
|
response.sendResponse = response.send;
|
||||||
|
response.send = (body) => {
|
||||||
|
client.set(key, JSON.stringify(body), 'EX', duration, function(err){
|
||||||
|
//client.set(key, JSON.stringify(body));
|
||||||
|
response.sendResponse(body);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
export const environment = {
|
export const environment = {
|
||||||
production: false,
|
production: false,
|
||||||
domain: '/',
|
domain: 'https://explorer.epic.tech/',
|
||||||
apiUrl: 'https://explorer.epic.tech/epic_explorer/v1',
|
apiUrl: 'https://explorer.epic.tech/epic_explorer/v1',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user