Added UI as submodule and as static in production, changed endpoint to /api/graphql

This commit is contained in:
Michele Marcucci 2018-11-06 10:19:49 +01:00
parent ea3ba51219
commit bdecda99ba
5 changed files with 190 additions and 171 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "apolloui"]
path = apolloui
url = https://github.com/CryptofyCH/apolloui

1
apolloui Submodule

@ -0,0 +1 @@
Subproject commit 95ae5ac443284b49fd81d94a396de340d8d7280f

1
config/production.json Normal file
View File

@ -0,0 +1 @@
{}

View File

@ -1,6 +1,7 @@
'use strict';
const sampleData = {
function getData() {
return {
"summary": [
{
"STATUS": [
@ -15,7 +16,7 @@ const sampleData = {
"SUMMARY": [
{
"Elapsed": 847,
"MHS av": 3.364,
"MHS av": getRandomFloat(3.00, 4.00),
"MHS 20s": 3.324,
"Found Blocks": 0,
"Getworks": 30,
@ -169,12 +170,21 @@ const sampleData = {
}
],
"id": 1
}
}
const net = require('net');
const PORT = 4028;
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 {
constructor(port, address) {
this.port = port || PORT;
@ -193,7 +203,7 @@ class Server {
sock.on('data', (data) => {
console.log(`${clientName} Says: ${data}`);
sock.write(JSON.stringify(sampleData));
sock.write(JSON.stringify(getData()));
// sock.write('exit');
});

View File

@ -1,9 +1,13 @@
const path = require('path')
const express = require('express')
const config = require('config')
const graphqlApp = require('./graphqlApp')
const buildPath = path.join(__dirname, '../../apolloui/build');
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