open source

This commit is contained in:
dingyi
2021-03-15 01:14:32 +08:00
commit f4f0d29a40
208 changed files with 24908 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
PORT=80
# local
# Mongodb_url=127.0.0.1:27017/look
# Mongodb_user=
# Mongodb_pwd=
# look
Mongodb_url=127.0.0.1:37777/look
Mongodb_user=look_20200415
Mongodb_pwd=@@look@@dingyi
# MONGODB_URL=mongodb://127.0.0.1:27017/look
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.
Binary file not shown.
+7
View File
@@ -0,0 +1,7 @@
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><title>LOOK Explorer - A light explorer for Cosmos based blockchains, Powered by ping.pub.</title><link rel=icon href=/favicon.ico><link rel=stylesheet href=/static/css/font_1354695_lrb2z8iklqe.css><script src=/static/cdn/vue@2.6.11.min.js></script><script src=/static/cdn/element-ui@2.13.0.js></script><link href=/js/chunk-dee43a6e.fa2f824d.js rel=prefetch><link href=/js/pc.3b9cf088.js rel=prefetch><link href=/js/index.9398c703.js rel=preload as=script></head><body><noscript><strong>We're sorry but look doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script>var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?612cb1567ca1cb640c7e9ee55b748c8c";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();</script><script src=/js/index.9398c703.js></script></body></html>
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+21
View File
File diff suppressed because one or more lines are too long
+8
View File
File diff suppressed because one or more lines are too long
+7
View File
@@ -0,0 +1,7 @@
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=apple-mobile-web-app-status-bar-style content=black><meta name=format-detection content="telephone=no"><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"><link rel=icon href=/favicon.ico><link rel=stylesheet href=/static/css/font_1354695_lrb2z8iklqe.css><script src=https://unpkg.com/vue@2.6.11/dist/vue.min.js></script><script src=https://unpkg.com/element-ui@2.13.0/lib/index.js></script><title>LOOK Explorer - A light explorer for Cosmos based blockchains, Powered by ping.pub.</title><link href=/js/h5.2e45d230.js rel=prefetch><link href=/js/m.6108a2ad.js rel=preload as=script></head><body><noscript><strong>We're sorry but look doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script>var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?612cb1567ca1cb640c7e9ee55b748c8c";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();</script><script src=/js/m.6108a2ad.js></script></body></html>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

+29
View File
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 319.97 320">
<defs>
<style>.cls-1{fill:url(#linear-gradient);}.cls-2{fill:url(#linear-gradient-2);}.cls-3{fill:url(#linear-gradient-3);}.cls-4{fill:url(#linear-gradient-4);}.cls-5{fill:url(#linear-gradient-5);}.cls-6{fill:url(#linear-gradient-6);}.cls-7{fill:url(#linear-gradient-7);}</style>
<linearGradient id="linear-gradient" x1="36.16" y1="24.77" x2="285.75" y2="274.37" gradientTransform="matrix(1, 0, 0, -1, -5.41, 313.57)" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#189dd8"/>
<stop offset="0.5" stop-color="#694ea0"/>
<stop offset="1" stop-color="#ed3855"/>
</linearGradient>
<linearGradient id="linear-gradient-2" x1="63.4" y1="-2.47" x2="312.99" y2="247.13" xlink:href="#linear-gradient"/>
<linearGradient id="linear-gradient-3" x1="134.61" y1="-73.68" x2="384.2" y2="175.91" xlink:href="#linear-gradient"/>
<linearGradient id="linear-gradient-4" x1="109.22" y1="-48.29" x2="358.82" y2="201.3" xlink:href="#linear-gradient"/>
<linearGradient id="linear-gradient-5" x1="-36.5" y1="97.43" x2="213.1" y2="347.02" xlink:href="#linear-gradient"/>
<linearGradient id="linear-gradient-6" x1="-61.81" y1="122.74" x2="187.78" y2="372.33" xlink:href="#linear-gradient"/>
<linearGradient id="linear-gradient-7" x1="9.4" y1="51.53" x2="258.99" y2="301.12" xlink:href="#linear-gradient"/>
</defs>
<title>Asset 1</title>
<g id="Layer_2">
<g id="Layer_1-2">
<path class="cls-1" d="M97.11,231.9l-73.39,8.26,43.09-99.45L22.68,80.5,130,68.3l29.16-67L223,88.1l73.41-8.26-42.9,99,43.81,59.74L190.59,250.72l-29.6,68Zm30.48-6.6a51.53,51.53,0,0,1-8.91,3.38l-2.8.78,41.39,56.26L172,251.94l-2.65-.34a52.91,52.91,0,0,1-36.1-21.36l-4.12-5.68Zm-14.39-51,33.39,46.2a36.31,36.31,0,0,0,29.33,15,35.61,35.61,0,0,0,4-.22L267,225.36l-34.69-47.31a35.77,35.77,0,0,0-5.91-6.32l-2-1.7-24.82,56-43.19-57.2Zm1.46-56.25A36.28,36.28,0,0,0,85.29,139.7l-35,80.74,58.12-6.53a35.22,35.22,0,0,0,8.4-2l2.48-.92L83.37,161.34l70.92-9,16.85-40.28Zm54.86,40.74,26.29,34.81,16-36.2,7.09-15.9a36.52,36.52,0,0,0-4-36.37L162.83,34.28,139.41,88.11a36,36,0,0,0-2.49,8.31L136.47,99l60.76-6.43Zm63.84-55.14,1,2.47a53.49,53.49,0,0,1-.39,42.1l-2.83,6.42,1.39.94a51,51,0,0,1,7.37,6.07l2.08,2,27.8-64.15ZM53,93.8,75.11,124l1.62-2.1a53,53,0,0,1,36.2-20.39l7-.73.12-1.69a52,52,0,0,1,1.75-10.37l.79-2.87Z"/>
<path class="cls-2" d="M144.51,320A158.79,158.79,0,0,1,29.93,253.61l18.54-2.11c3.08,3.77,6.34,7.39,9.71,10.77a142.87,142.87,0,0,0,72.93,39.48Z"/>
<path class="cls-3" d="M183.17,302.82a142.36,142.36,0,0,0,78.65-40.52c1.93-1.94,3.89-4,5.82-6.2l22.51-2.6A158.89,158.89,0,0,1,175.7,320Z"/>
<path class="cls-4" d="M294.72,211.3a146.54,146.54,0,0,0,2-96.94l9-20.8a161.83,161.83,0,0,1,0,132.8Z"/>
<path class="cls-5" d="M14.33,226.58a161.85,161.85,0,0,1,.16-133.51l11,15a146.46,146.46,0,0,0-2.17,97.7Z"/>
<path class="cls-6" d="M30.59,65.5A159,159,0,0,1,144.42,0L137,17.16A142.34,142.34,0,0,0,58.18,57.7c-1.63,1.63-3.28,3.38-4.92,5.19Z"/>
<path class="cls-7" d="M271.59,68.5c-3.08-3.78-6.34-7.4-9.72-10.79a142.81,142.81,0,0,0-72.8-39.45L175.59,0A158.89,158.89,0,0,1,290.08,66.4Z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.1 KiB

+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 193.63 213">
<defs>
<style>.cls-1{opacity:0.2;}.cls-2{fill:#ff564f;}</style>
</defs>
<title>Kava Logo</title>
<g id="Layer_2">
<g id="Layer_1-2">
<g class="cls-1">
<polygon class="cls-2" points="30 213 111.63 106.85 30 0 20.25 38.34 72.81 106.85 22.66 171.3 30 213"/>
</g>
<polygon class="cls-2" points="154.34 213 72.21 106.85 154.13 0 193 0 111.03 106.85 193.63 213 154.34 213"/>
<rect class="cls-2" width="30" height="213"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 537 B

File diff suppressed because one or more lines are too long
Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 956 KiB

+28
View File
@@ -0,0 +1,28 @@
{
"name": "look",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "pm2 start pm2.json",
"dev": "nodemon src/main.js",
"test": "node app.js"
},
"keywords": [],
"author": "dingyiming",
"license": "ISC",
"dependencies": {
"compression": "^1.7.4",
"dayjs": "^1.8.23",
"dotenv": "^8.2.0",
"express": "^4.16.3",
"express-useragent": "^1.0.13",
"express-validator": "^6.4.0",
"http-proxy-middleware": "^0.19.0",
"mongoose": "^5.9.7",
"nunjucks": "^3.1.3"
},
"devDependencies": {
"nodemon": "^2.0.3"
}
}
+10
View File
@@ -0,0 +1,10 @@
{
"apps": [{
"name": "look",
"script": "./src/main.js",
"out_fil": "~/look.log",
"watch": true,
"instances" : "1",
"exec_mode" : "cluster"
}]
}
+12
View File
@@ -0,0 +1,12 @@
const mongoose = require("mongoose");
mongoose.set("useCreateIndex", true);
mongoose.connect(`mongodb://${process.env.Mongodb_url}?authSource=admin`, {
useNewUrlParser: true,
useUnifiedTopology: true,
user: process.env.Mongodb_user,
pass: process.env.Mongodb_pwd,
});
const db = mongoose.connection;
db.once("open", () => {
console.log("[dingyi]小芒果连上了~~");
});
+15
View File
@@ -0,0 +1,15 @@
/*
* @Description:
* @Autor: dingyi
* @Date: 2020-04-10 12:40:50
* @LastEditors: dingyi
* @LastEditTime: 2020-04-13 11:39:02
* @FilePath: /look-web/server/src/base/router.js
*/
const api = require('../routes/index.js')
module.exports = (app) => {
app.use('/look', api)
app.use('/look', (req, res) => { res.send('look.ping.pub') })
}
+57
View File
@@ -0,0 +1,57 @@
/*
* @Description:
* @Autor: dingyi
* @Date: 2020-04-13 11:21:32
* @LastEditors: dingyi
* @LastEditTime: 2020-04-13 14:50:25
* @FilePath: /look-web/server/src/base/utils.js
*/
const { validationResult } = require("express-validator");
exports.ok = ok
function ok(res, data, other) {
let obj = {
code: 1,
msg: "ok",
data,
};
if (other) {
obj = {
...obj,
...other,
};
}
res.json(obj);
}
function routerGet(router, uri, valid, logic) {
router.get(uri, valid(), (req, res) => {
const errors = validationResult(req);
if (!errors.isEmpty())
return ok(res, null, {
code: 2,
msg: errors.array()[0].msg,
data: errors.array(),
});
logic(req, res);
});
}
function routerPost(router, uri, valid, logic) {
router.post(uri, valid(), (req, res) => {
const errors = validationResult(req);
if (!errors.isEmpty())
return ok(res, null, {
code: 2,
msg: errors.array()[0].msg,
data: errors.array(),
});
logic(req, res);
});
}
exports.routerRun = {
get: routerGet,
post: routerPost
}
+123
View File
@@ -0,0 +1,123 @@
/*
* @Description:
* @Autor: dingyi
* @Date: 2020-04-13 23:03:22
* @LastEditors: dingyi
* @LastEditTime: 2020-04-13 23:53:51
* @FilePath: \look-web\server\src\initChains.js
*/
module.exports = {
Mainnet: [
{
"chainId": "cosmoshub-3",
"lcd": "https://lcd.nylira.net",
"logo": "/static/chains/cosmoshub.svg",
"name": "Cosmos Hub",
"rpc": "https://rpc.nylira.net",
"version": "0.32.7",
"api": 'V1',
"unit": 'ATOM',
"prefix": 'cosmos',
"host": 'cosmos.ping.pub',
},
{
"chainId": "kava-2",
"lcd": "https://kava-relay.01node.com",
"logo": "/static/chains/kava.svg",
"name": "Kava",
"rpc": "http://13.125.71.131:26657",
"version": "0.32.7",
"api": 'V1',
"unit": 'KAVA',
"prefix": 'kava',
"host": 'kava.ping.pub'
},
{
"chainId": "irishub",
"lcd": "https://rpc.irisnet.org",
"logo": "/static/chains/irishub.svg",
"name": "IRISnet",
"rpc": "http://seed-1.mainnet.irisnet.org:26657",
"version": "0.32.1",
"api": 'V2',
"unit": 'IRIS',
"prefix": 'iaa',
"host": 'iris.ping.pub'
},
{
"chainId": "e-money",
"lcd": "http://emoney.validator.network/light",
"logo": "/static/chains/cosmoshub.svg",
"name": "e-money",
"rpc": "https://emoney.validator.network",
"version": "0.32.7",
"api": 'V1',
"unit": '',
"prefix": '', // 地址前缀
"host": 'e-money.ping.pub'
}
],
Testnet: [
{
"chainId": "sentinelhub-test",
"lcd": "https://lcd.turing.sentinel.co",
"logo": "/static/chains/cosmoshub.svg",
"name": "Sentinel Network",
"rpc": "https://rpc.turing.sentinel.co",
"version": "0.32.7",
"api": 'V1',
"prefix": '',
"unit": '',
"host": 'sentinel-test.ping.pub'
},
{
"chainId": "cell-test-01",
"lcd": "http://sz1.icell.one:1317",
"logo": "/static/chains/cosmoshub.svg",
"name": "Cell Network",
"rpc": "http://sz1.icell.one:26657",
"version": "0.32.7",
"prefix": 'cosmos',
"api": 'V1',
"unit": '',
"host": 'cell-test.ping.pub'
},
{
"chainId": "cyber-test",
"lcd": "https://titan.cybernode.ai/lcd",
"logo": "/static/chains/cosmoshub.svg",
"name": "cyber",
"rpc": "https://titan.cybernode.ai/api",
"version": "0.32.7",
"api": 'V1',
"prefix": '',
"unit": '',
"host": 'cyber-test.ping.pub'
},
{
"chainId": "e-money-test",
"lcd": "https://lilmermaid.validator.network/light",
"logo": "/static/chains/cosmoshub.svg",
"name": "e-money",
"rpc": "https://lilmermaid.validator.network",
"version": "0.32.7",
"api": 'V1',
"unit": '',
"prefix": '', // 地址前缀
"host": 'e-money-test.ping.pub'
},
// {
// "chainId": "new-test",
// "lcd": "https://lcd.nylira.net",
// "logo": "/static/chains/cosmoshub.svg",
// "name": "Genesis Test",
// "rpc": "https://rpc.nylira.net",
// "version": "0.32.7",
// "api": 'V1',
// "unit": 'ATOM',
// "prefix": 'cosmos',
// "host": '',
// "genesis_time": '2020-05-01'
// },
]
}
+92
View File
@@ -0,0 +1,92 @@
/*
* @Description:
* @Autor: dingyi
* @Date: 2020-03-27 11:41:45
* @LastEditors: Please set LastEditors
* @LastEditTime: 2020-04-16 00:20:19
* @FilePath: \look-web\server\src\main.js
*/
// 环境配置
require('dotenv').config()
// 数据库
require('./base/mongodb.js')
var express = require('express');
var app = express();
app.use(express.json());
var router = express.Router();
// gzip
const compression = require('compression')
app.use(compression())
// ua
var useragent = require('express-useragent');
app.use(useragent.express());
// proxy
var proxy = require('http-proxy-middleware');
// 根据请求转发
app.use('/api*', proxy({
target: 'https://lcd.nylira.net',
changeOrigin: true,
pathRewrite: {
['^/api']: ''
},
router: function (req) {
return req.headers.server || 'https://lcd.nylira.net';
}
}))
router.get('/', function (req, res, next) {
var isMobile = req.useragent.isMobile
console.log('移动端', isMobile)
let render = isMobile ? 'm.html' : 'index.html'
res.render(render);
});
router.get('/validator', function (req, res, next) {
res.redirect('/#/validator');
});
router.get('/uptime', function (req, res, next) {
res.redirect('/#/uptime');
});
router.get('/block', function (req, res, next) {
res.redirect('/#/block');
});
router.get('/proposal', function (req, res, next) {
res.redirect('/#/governance');
});
router.get('/parameter', function (req, res, next) {
res.redirect('/#/parameter');
});
app.use('/', router);
// 路由
require('./base/router.js')(app)
var nunjucks = require('nunjucks')
nunjucks.configure('dist', {
autoescape: true,
express: app
});
// static cache
var path = require('path');
app.use(express.static(path.join(__dirname, '../dist'), {
maxAge: '1y',
expires: '1y',
Etag: false,
lastModified: false
}));
var server = app.listen(process.env.PORT, function () {
var host = server.address().address;
var port = server.address().port;
console.log('app listening at http://%s:%s', host, port);
});
+60
View File
@@ -0,0 +1,60 @@
/*
* @Description:
{
"chainId": "cosmoshub-3",
"lcd": "https://lcd.nylira.net",
"logo": "/static/chains/cosmoshub.svg",
"name": "Cosmos Hub",
"rpc": "https://rpc.nylira.net",
"version": "0.32.7",
"api": 'V1',
"unit": 'ATOM',
"prefix": 'cosmos',
"host": isDev ? '' : 'cosmos.ping.pub'
},
* @Autor: dingyi
* @Date: 2020-04-13 11:13:34
* @LastEditors: dingyi
* @LastEditTime: 2020-04-13 23:16:37
* @FilePath: \look-web\server\src\models\chain.js
*/
var mongoose = require('mongoose');
const dayjs = require('dayjs')
var Schema = mongoose.Schema;
const tableSchema = new Schema({
// 分类 Mainnet Testnet GOZ
type: {
type: String, index: true
},
// 显示名称
name: String,
logo: String,
chainId: String,
desc: String,
lcd: String,
rpc: String,
version: String,
// 接口版本 V1 类 cosmoshub V2 类 irishub
api: String,
unit: String,
prefix: String,
host: String,
genesis_time: Date,
// 创建时间
created: { type: Date, default: Date.now },
// 更新时间
updated: { type: Date, default: Date.now }
})
tableSchema.methods.toJSONObject = function () {
return {
name: this.name,
logo: this.logo,
code: this.code,
created: dayjs(this.created).format('YYY MM DD HH:MM:ss'),
updated: dayjs(this.updated).format('YYY MM DD HH:MM:ss')
}
}
module.exports = mongoose.model("look_chain", tableSchema);
+36
View File
@@ -0,0 +1,36 @@
/*
* @Description: 创建链
* @Autor: dingyi
* @Date: 2020-04-13 11:20:07
* @LastEditors: dingyi
* @LastEditTime: 2020-04-25 21:59:43
* @FilePath: \look-web\server\src\routes\chain_create.js
*/
const { ok, routerRun } = require("../base/utils.js");
const { body } = require("express-validator");
const Chain = require("../models/chain");
module.exports = (router) => {
// 路由
const uri = "/chain/create";
// 验证
const valid = () => {
return [
body("name").notEmpty(),
body("lcd").notEmpty(),
body("rpc").notEmpty(),
body("api").notEmpty(),
body("type").notEmpty()
];
};
// 逻辑
const logic = async (req, res) => {
const row = new Chain({ ...req.body });
await row.save();
ok(res);
};
// 封装
routerRun.post(router, uri, valid, logic)
};
+42
View File
@@ -0,0 +1,42 @@
/*
* @Description: 创建链
* @Autor: dingyi
* @Date: 2020-04-13 11:20:07
* @LastEditors: dingyi
* @LastEditTime: 2020-04-15 22:26:50
* @FilePath: /look-web/server/src/routes/chain_delete.js
*/
const { ok, routerRun } = require("../base/utils.js");
const { body } = require("express-validator");
const mongoose = require('mongoose');
const Chain = require("../models/chain");
module.exports = (router) => {
// 路由
const uri = "/chain/delete";
// 验证
const valid = () => {
return [
body("lookpwd").notEmpty(),
body("ids").notEmpty(),
body("lookpwd").custom(async (value, { req }) => {
if (value !== "@ping@dddd")
throw new Error("密码错误");
return true;
}),
];
};
// 逻辑
const logic = async (req, res) => {
const ids = req.body.ids
for (let id of ids) {
id = mongoose.Types.ObjectId(id);
}
const row = await Chain.deleteMany({ _id: { $in: ids } });
ok(res, row);
};
// 封装
routerRun.post(router, uri, valid, logic)
};
+38
View File
@@ -0,0 +1,38 @@
/*
* @Description:
* @Autor: dingyi
* @Date: 2020-04-13 22:38:46
* @LastEditors: dingyi
* @LastEditTime: 2020-04-13 23:10:45
* @FilePath: \look-web\server\src\routes\chain_init.js
*/
const { ok, routerRun } = require("../base/utils.js");
const Chain = require("../models/chain");
const initChains = require('../initChains')
module.exports = (router) => {
// 路由
const uri = "/chain/init";
// 验证
const valid = () => {
return [];
};
// 逻辑
const logic = async (req, res) => {
const Mainnet = initChains.Mainnet
for (const item of Mainnet) {
const row = new Chain({ ...item, type: 'Mainnet' });
await row.save();
}
const Testnet = initChains.Testnet
for (const item of Testnet) {
const row = new Chain({ ...item, type: 'Testnet' });
await row.save();
}
ok(res);
};
// 封装
routerRun.post(router, uri, valid, logic)
};
+29
View File
@@ -0,0 +1,29 @@
/*
* @Description: 查询链
* @Autor: dingyi
* @Date: 2020-04-13 11:20:07
* @LastEditors: dingyi
* @LastEditTime: 2020-04-15 22:34:02
* @FilePath: /look-web/server/src/routes/chain.js
*/
const { ok, routerRun } = require("../base/utils.js");
const Chain = require("../models/chain");
module.exports = (router) => {
// 路由
const uri = "/chain/list";
// 验证
const valid = () => {
return [
];
};
// 逻辑
const logic = async (req, res) => {
const rows = await Chain.find().exec()
ok(res, rows);
};
// 封装
routerRun.post(router, uri, valid, logic)
};
+68
View File
@@ -0,0 +1,68 @@
/*
* @Description: 查询链
* @Autor: dingyi
* @Date: 2020-04-13 11:20:07
* @LastEditors: dingyi
* @LastEditTime: 2020-04-25 21:55:10
* @FilePath: \look-web\server\src\routes\chain_type.js
*/
const { ok, routerRun } = require("../base/utils.js");
const { query } = require("express-validator");
const Chain = require("../models/chain");
module.exports = (router) => {
// 路由
const uri = "/chain/type";
// 验证
const valid = () => {
return [
];
};
// 逻辑
const logic = async (req, res) => {
const rows = await Chain.aggregate([
{
$group: {
_id: "$type",
chains: {
$push: {
hash: '$_id',
api: '$api',
chainId: '$chainId',
name: '$name',
lcd: '$lcd',
rpc: '$rpc',
logo: '$logo',
prefix: '$prefix',
unit: '$unit',
genesis_time: '$genesis_time',
host: '$host',
// version: '$version',
// type: '$type',
// created: '$created',
// updated: '$updated'
},
}
}
},
{
$sort: {
created: 1
}
}
]).exec()
const obj = {}
for (const item of rows) {
obj[item._id] = item.chains
}
ok(res, {
Mainnet: obj['Mainnet'],
Testnet: obj['Testnet'],
GoZ: obj['GoZ'],
});
};
// 封装
routerRun.get(router, uri, valid, logic)
};
+25
View File
@@ -0,0 +1,25 @@
/*
* @Description: routes list
* @Autor: dingyi
* @Date: 2020-04-08 16:30:15
* @LastEditors: dingyi
* @LastEditTime: 2020-04-15 22:27:07
* @FilePath: /look-web/server/src/routes/index.js
*/
const routes = [
'chain_create',
'chain_type',
'chain_init',
'chain_delete',
'chain_list'
]
const express = require('express')
const router = express.Router()
for (const item of routes) {
require(`./${item}`)(router)
}
module.exports = router