mirror of
https://github.com/Retropex/apolloapi-v2.git
synced 2025-05-21 17:42:33 +02:00
Added UI as submodule and as static in production, changed endpoint to /api/graphql
This commit is contained in:
parent
ea3ba51219
commit
bdecda99ba
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "apolloui"]
|
||||||
|
path = apolloui
|
||||||
|
url = https://github.com/CryptofyCH/apolloui
|
1
apolloui
Submodule
1
apolloui
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 95ae5ac443284b49fd81d94a396de340d8d7280f
|
1
config/production.json
Normal file
1
config/production.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{}
|
@ -1,179 +1,189 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const sampleData = {
|
function getData() {
|
||||||
"summary": [
|
return {
|
||||||
{
|
"summary": [
|
||||||
"STATUS": [
|
{
|
||||||
{
|
"STATUS": [
|
||||||
"STATUS": "S",
|
{
|
||||||
"When": 1541144892,
|
"STATUS": "S",
|
||||||
"Code": 11,
|
"When": 1541144892,
|
||||||
"Msg": "Summary",
|
"Code": 11,
|
||||||
"Description": "bfgminer 5.4.2"
|
"Msg": "Summary",
|
||||||
}
|
"Description": "bfgminer 5.4.2"
|
||||||
],
|
}
|
||||||
"SUMMARY": [
|
],
|
||||||
{
|
"SUMMARY": [
|
||||||
"Elapsed": 847,
|
{
|
||||||
"MHS av": 3.364,
|
"Elapsed": 847,
|
||||||
"MHS 20s": 3.324,
|
"MHS av": getRandomFloat(3.00, 4.00),
|
||||||
"Found Blocks": 0,
|
"MHS 20s": 3.324,
|
||||||
"Getworks": 30,
|
"Found Blocks": 0,
|
||||||
"Accepted": 168,
|
"Getworks": 30,
|
||||||
"Rejected": 0,
|
"Accepted": 168,
|
||||||
"Hardware Errors": 2,
|
"Rejected": 0,
|
||||||
"Utility": 11.9,
|
"Hardware Errors": 2,
|
||||||
"Discarded": 78,
|
"Utility": 11.9,
|
||||||
"Stale": 0,
|
"Discarded": 78,
|
||||||
"Get Failures": 0,
|
"Stale": 0,
|
||||||
"Local Work": 138,
|
"Get Failures": 0,
|
||||||
"Remote Failures": 0,
|
"Local Work": 138,
|
||||||
"Network Blocks": 5,
|
"Remote Failures": 0,
|
||||||
"Total MH": 2849.3488,
|
"Network Blocks": 5,
|
||||||
"Diff1 Work": 0.67822266,
|
"Total MH": 2849.3488,
|
||||||
"Work Utility": 0.048,
|
"Diff1 Work": 0.67822266,
|
||||||
"Difficulty Accepted": 0.65625,
|
"Work Utility": 0.048,
|
||||||
"Difficulty Rejected": 0,
|
"Difficulty Accepted": 0.65625,
|
||||||
"Difficulty Stale": 0,
|
"Difficulty Rejected": 0,
|
||||||
"Best Share": 1.03726997,
|
"Difficulty Stale": 0,
|
||||||
"Device Hardware%": 0.1438,
|
"Best Share": 1.03726997,
|
||||||
"Device Rejected%": 0,
|
"Device Hardware%": 0.1438,
|
||||||
"Pool Rejected%": 0,
|
"Device Rejected%": 0,
|
||||||
"Pool Stale%": 0,
|
"Pool Rejected%": 0,
|
||||||
"Last getwork": 1541144888
|
"Pool Stale%": 0,
|
||||||
}
|
"Last getwork": 1541144888
|
||||||
],
|
}
|
||||||
"id": 1
|
],
|
||||||
}
|
"id": 1
|
||||||
],
|
}
|
||||||
"devs": [
|
],
|
||||||
{
|
"devs": [
|
||||||
"STATUS": [
|
{
|
||||||
{
|
"STATUS": [
|
||||||
"STATUS": "S",
|
{
|
||||||
"When": 1541144892,
|
"STATUS": "S",
|
||||||
"Code": 9,
|
"When": 1541144892,
|
||||||
"Msg": "1 PGA(s)",
|
"Code": 9,
|
||||||
"Description": "bfgminer 5.4.2"
|
"Msg": "1 PGA(s)",
|
||||||
}
|
"Description": "bfgminer 5.4.2"
|
||||||
],
|
}
|
||||||
"DEVS": [
|
],
|
||||||
{
|
"DEVS": [
|
||||||
"PGA": 0,
|
{
|
||||||
"Name": "MLD",
|
"PGA": 0,
|
||||||
"ID": 0,
|
"Name": "MLD",
|
||||||
"Enabled": "Y",
|
"ID": 0,
|
||||||
"Status": "Alive",
|
"Enabled": "Y",
|
||||||
"Device Elapsed": 847,
|
"Status": "Alive",
|
||||||
"MHS av": 3.363,
|
"Device Elapsed": 847,
|
||||||
"MHS 20s": 3.373,
|
"MHS av": 3.363,
|
||||||
"MHS rolling": 3.373,
|
"MHS 20s": 3.373,
|
||||||
"Accepted": 168,
|
"MHS rolling": 3.373,
|
||||||
"Rejected": 0,
|
"Accepted": 168,
|
||||||
"Hardware Errors": 2,
|
"Rejected": 0,
|
||||||
"Utility": 11.897,
|
"Hardware Errors": 2,
|
||||||
"Stale": 0,
|
"Utility": 11.897,
|
||||||
"Last Share Pool": 1,
|
"Stale": 0,
|
||||||
"Last Share Time": 1541144887,
|
"Last Share Pool": 1,
|
||||||
"Total MH": 2849.3488,
|
"Last Share Time": 1541144887,
|
||||||
"Diff1 Work": 0.67822266,
|
"Total MH": 2849.3488,
|
||||||
"Work Utility": 0.048,
|
"Diff1 Work": 0.67822266,
|
||||||
"Difficulty Accepted": 0.65625,
|
"Work Utility": 0.048,
|
||||||
"Difficulty Rejected": 0,
|
"Difficulty Accepted": 0.65625,
|
||||||
"Difficulty Stale": 0,
|
"Difficulty Rejected": 0,
|
||||||
"Last Share Difficulty": 0.00390625,
|
"Difficulty Stale": 0,
|
||||||
"Last Valid Work": 1541144891,
|
"Last Share Difficulty": 0.00390625,
|
||||||
"Device Hardware%": 0.1438,
|
"Last Valid Work": 1541144891,
|
||||||
"Device Rejected%": 0
|
"Device Hardware%": 0.1438,
|
||||||
}
|
"Device Rejected%": 0
|
||||||
],
|
}
|
||||||
"id": 1
|
],
|
||||||
}
|
"id": 1
|
||||||
],
|
}
|
||||||
"pools": [
|
],
|
||||||
{
|
"pools": [
|
||||||
"STATUS": [
|
{
|
||||||
{
|
"STATUS": [
|
||||||
"STATUS": "S",
|
{
|
||||||
"When": 1541144892,
|
"STATUS": "S",
|
||||||
"Code": 7,
|
"When": 1541144892,
|
||||||
"Msg": "2 Pool(s)",
|
"Code": 7,
|
||||||
"Description": "bfgminer 5.4.2"
|
"Msg": "2 Pool(s)",
|
||||||
}
|
"Description": "bfgminer 5.4.2"
|
||||||
],
|
}
|
||||||
"POOLS": [
|
],
|
||||||
{
|
"POOLS": [
|
||||||
"POOL": 0,
|
{
|
||||||
"URL": "stratum+tcp://us.litecoinpool.org:3333",
|
"POOL": 0,
|
||||||
"Status": "Alive",
|
"URL": "stratum+tcp://us.litecoinpool.org:3333",
|
||||||
"Priority": 1,
|
"Status": "Alive",
|
||||||
"Quota": 1,
|
"Priority": 1,
|
||||||
"Mining Goal": "default",
|
"Quota": 1,
|
||||||
"Long Poll": "N",
|
"Mining Goal": "default",
|
||||||
"Getworks": 3,
|
"Long Poll": "N",
|
||||||
"Accepted": 0,
|
"Getworks": 3,
|
||||||
"Rejected": 0,
|
"Accepted": 0,
|
||||||
"Works": 0,
|
"Rejected": 0,
|
||||||
"Discarded": 0,
|
"Works": 0,
|
||||||
"Stale": 0,
|
"Discarded": 0,
|
||||||
"Get Failures": 0,
|
"Stale": 0,
|
||||||
"Remote Failures": 0,
|
"Get Failures": 0,
|
||||||
"User": "jstefanop.1",
|
"Remote Failures": 0,
|
||||||
"Last Share Time": 0,
|
"User": "jstefanop.1",
|
||||||
"Diff1 Shares": 0,
|
"Last Share Time": 0,
|
||||||
"Proxy": "",
|
"Diff1 Shares": 0,
|
||||||
"Difficulty Accepted": 0,
|
"Proxy": "",
|
||||||
"Difficulty Rejected": 0,
|
"Difficulty Accepted": 0,
|
||||||
"Difficulty Stale": 0,
|
"Difficulty Rejected": 0,
|
||||||
"Last Share Difficulty": 0,
|
"Difficulty Stale": 0,
|
||||||
"Has Stratum": true,
|
"Last Share Difficulty": 0,
|
||||||
"Stratum Active": false,
|
"Has Stratum": true,
|
||||||
"Stratum URL": "",
|
"Stratum Active": false,
|
||||||
"Best Share": 0,
|
"Stratum URL": "",
|
||||||
"Pool Rejected%": 0,
|
"Best Share": 0,
|
||||||
"Pool Stale%": 0
|
"Pool Rejected%": 0,
|
||||||
},
|
"Pool Stale%": 0
|
||||||
{
|
},
|
||||||
"POOL": 1,
|
{
|
||||||
"URL": "stratum+tcp://us.litecoinpool.org:3333",
|
"POOL": 1,
|
||||||
"Status": "Alive",
|
"URL": "stratum+tcp://us.litecoinpool.org:3333",
|
||||||
"Priority": 0,
|
"Status": "Alive",
|
||||||
"Quota": 1,
|
"Priority": 0,
|
||||||
"Mining Goal": "default",
|
"Quota": 1,
|
||||||
"Long Poll": "N",
|
"Mining Goal": "default",
|
||||||
"Getworks": 27,
|
"Long Poll": "N",
|
||||||
"Accepted": 168,
|
"Getworks": 27,
|
||||||
"Rejected": 0,
|
"Accepted": 168,
|
||||||
"Works": 30,
|
"Rejected": 0,
|
||||||
"Discarded": 78,
|
"Works": 30,
|
||||||
"Stale": 0,
|
"Discarded": 78,
|
||||||
"Get Failures": 0,
|
"Stale": 0,
|
||||||
"Remote Failures": 0,
|
"Get Failures": 0,
|
||||||
"User": "jstefanop.1",
|
"Remote Failures": 0,
|
||||||
"Last Share Time": 1541144887,
|
"User": "jstefanop.1",
|
||||||
"Diff1 Shares": 0.67822266,
|
"Last Share Time": 1541144887,
|
||||||
"Proxy": "",
|
"Diff1 Shares": 0.67822266,
|
||||||
"Difficulty Accepted": 0.65625,
|
"Proxy": "",
|
||||||
"Difficulty Rejected": 0,
|
"Difficulty Accepted": 0.65625,
|
||||||
"Difficulty Stale": 0,
|
"Difficulty Rejected": 0,
|
||||||
"Last Share Difficulty": 0.00390625,
|
"Difficulty Stale": 0,
|
||||||
"Has Stratum": true,
|
"Last Share Difficulty": 0.00390625,
|
||||||
"Stratum Active": true,
|
"Has Stratum": true,
|
||||||
"Stratum URL": "us.litecoinpool.org",
|
"Stratum Active": true,
|
||||||
"Best Share": 1.03726997,
|
"Stratum URL": "us.litecoinpool.org",
|
||||||
"Pool Rejected%": 0,
|
"Best Share": 1.03726997,
|
||||||
"Pool Stale%": 0
|
"Pool Rejected%": 0,
|
||||||
}
|
"Pool Stale%": 0
|
||||||
],
|
}
|
||||||
"id": 1
|
],
|
||||||
}
|
"id": 1
|
||||||
],
|
}
|
||||||
"id": 1
|
],
|
||||||
|
"id": 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
const PORT = 4028;
|
const PORT = 4028;
|
||||||
const HOST = 'localhost';
|
const HOST = 'localhost';
|
||||||
|
|
||||||
|
function getRandomArbitrary(min, max) {
|
||||||
|
return Math.random() * (max - min) + min;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRandomFloat(min, max) {
|
||||||
|
return parseFloat(Math.random() * (max - min) + min);
|
||||||
|
}
|
||||||
|
|
||||||
class Server {
|
class Server {
|
||||||
constructor(port, address) {
|
constructor(port, address) {
|
||||||
@ -193,7 +203,7 @@ class Server {
|
|||||||
|
|
||||||
sock.on('data', (data) => {
|
sock.on('data', (data) => {
|
||||||
console.log(`${clientName} Says: ${data}`);
|
console.log(`${clientName} Says: ${data}`);
|
||||||
sock.write(JSON.stringify(sampleData));
|
sock.write(JSON.stringify(getData()));
|
||||||
// sock.write('exit');
|
// sock.write('exit');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
|
const path = require('path')
|
||||||
const express = require('express')
|
const express = require('express')
|
||||||
const config = require('config')
|
const config = require('config')
|
||||||
const graphqlApp = require('./graphqlApp')
|
const graphqlApp = require('./graphqlApp')
|
||||||
|
const buildPath = path.join(__dirname, '../../apolloui/build');
|
||||||
|
|
||||||
const app = express()
|
const app = express()
|
||||||
|
|
||||||
app.use('/graphql', graphqlApp)
|
app.use('/api/graphql', graphqlApp)
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV === 'production') app.use(express.static(buildPath));
|
||||||
|
|
||||||
module.exports = app
|
module.exports = app
|
||||||
|
Loading…
Reference in New Issue
Block a user