React routes now work on page refresh. Use https://github.com/emizzle/embark-demo-react-routes as a sample dapp to run this repo's embark against.
/embark errors currently and crashes embark process. WIP Few fixes from rebase.
This commit is contained in:
parent
44dced6e8a
commit
7ea705fddc
|
@ -1,5 +1,5 @@
|
|||
const async = require('async');
|
||||
|
||||
const ServicesMonitor = require('./services_monitor');
|
||||
const utils = require('../utils/utils');
|
||||
const IPC = require('./ipc');
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ var express = require('express');
|
|||
let path = require('path');
|
||||
var expressWebSocket = require('express-ws');
|
||||
var bodyParser = require('body-parser');
|
||||
const fs = require('../../core/fs');
|
||||
|
||||
class Server {
|
||||
constructor(options) {
|
||||
|
@ -31,21 +32,33 @@ class Server {
|
|||
var app = express();
|
||||
|
||||
app.use(serve);
|
||||
app.use('/embark', serveStatic(path.join(__dirname, 'backend'), {'backend': ['index.html', 'index.htm']}));
|
||||
//app.use('/embark', serveStatic(path.join(__dirname, 'backend'), {'backend': ['index.html', 'index.htm']}));
|
||||
//app.use('/backend', serveStatic(path.join(__dirname, 'backend'), {'backend': ['index.html', 'index.htm']}));
|
||||
app.get('/embark', function (req, res) {
|
||||
res.sendFile(path.join(__dirname, 'backend', 'index.html'));
|
||||
});
|
||||
|
||||
app.use(bodyParser.json()); // support json encoded bodies
|
||||
app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies
|
||||
app.use(bodyParser.urlencoded({extended: true})); // support encoded bodies
|
||||
|
||||
expressWebSocket(app);
|
||||
|
||||
let apiCalls = self.plugins.getPluginsProperty("apiCalls", "apiCalls");
|
||||
for (let apiCall of apiCalls) {
|
||||
app[apiCall.method].apply(app, [apiCall.endpoint, apiCall.cb]);
|
||||
if(self.plugins){
|
||||
let apiCalls = self.plugins.getPluginsProperty("apiCalls", "apiCalls");
|
||||
for (let apiCall of apiCalls) {
|
||||
app[apiCall.method].apply(app, [apiCall.endpoint, apiCall.cb]);
|
||||
}
|
||||
}
|
||||
|
||||
app.get('/embark', function (req, res) {
|
||||
res.send('Welcome to Embark')
|
||||
// app.get('/embark', function (req, res) {
|
||||
// res.send('Welcome to Embark');
|
||||
// });
|
||||
|
||||
// support react routes
|
||||
// suggested changes from https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#serving-apps-with-client-side-routing
|
||||
app.use(express.static(path.join(fs.dappPath(this.dist))));
|
||||
app.get('/*', function (req, res) {
|
||||
res.sendFile(path.join(fs.dappPath(self.dist, 'index.html')));
|
||||
});
|
||||
|
||||
app.listen(this.port);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -85,6 +85,8 @@
|
|||
"uuid": "^3.2.1",
|
||||
"viz.js": "^1.8.1",
|
||||
"web3": "1.0.0-beta.34",
|
||||
"web3-bzz": "^1.0.0-beta.34",
|
||||
"web3-provider-engine": "^14.0.5",
|
||||
"webpack": "^3.10.0",
|
||||
"window-size": "^1.1.0"
|
||||
},
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
"dom-helpers": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-3.3.1.tgz",
|
||||
"integrity": "sha1-/BpOFf/fYN3eA6SAqcD+zoId1KY="
|
||||
"integrity": "sha512-2Sm+JaYn74OiTM2wHvxJOo3roiq/h25Yi69Fqk269cNUwIXsCvATB6CRSFC9Am/20G2b28hGv/+7NiWydIrPvg=="
|
||||
},
|
||||
"dotenv": {
|
||||
"version": "4.0.0",
|
||||
|
@ -229,7 +229,7 @@
|
|||
"node-fetch": {
|
||||
"version": "1.7.3",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz",
|
||||
"integrity": "sha1-mA9vcthSEaU0fGsrwYxbhMPrR+8=",
|
||||
"integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==",
|
||||
"requires": {
|
||||
"encoding": "^0.1.11",
|
||||
"is-stream": "^1.0.1"
|
||||
|
@ -252,7 +252,7 @@
|
|||
"promise": {
|
||||
"version": "7.3.1",
|
||||
"resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz",
|
||||
"integrity": "sha1-BktyYCsY+Q8pGSuLG8QY/9Hr078=",
|
||||
"integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==",
|
||||
"requires": {
|
||||
"asap": "~2.0.3"
|
||||
}
|
||||
|
@ -289,7 +289,7 @@
|
|||
"react-bootstrap": {
|
||||
"version": "0.32.1",
|
||||
"resolved": "https://registry.npmjs.org/react-bootstrap/-/react-bootstrap-0.32.1.tgz",
|
||||
"integrity": "sha1-YGJMG0ijnXc+9szmQhpPM+zBZrs=",
|
||||
"integrity": "sha512-RbfzKUbsukWsToWqGHfCCyMFq9QQI0TznutdyxyJw6dih2NvIne25Mrssg8LZsprqtPpyQi8bN0L0Fx3fUsL8Q==",
|
||||
"requires": {
|
||||
"babel-runtime": "^6.11.6",
|
||||
"classnames": "^2.2.5",
|
||||
|
@ -319,7 +319,7 @@
|
|||
"react-overlays": {
|
||||
"version": "0.8.3",
|
||||
"resolved": "https://registry.npmjs.org/react-overlays/-/react-overlays-0.8.3.tgz",
|
||||
"integrity": "sha1-+tZe6lskMBzKGSoWn13dsLINOsU=",
|
||||
"integrity": "sha512-h6GT3jgy90PgctleP39Yu3eK1v9vaJAW73GOA/UbN9dJ7aAN4BTZD6793eI1D5U+ukMk17qiqN/wl3diK1Z5LA==",
|
||||
"requires": {
|
||||
"classnames": "^2.2.5",
|
||||
"dom-helpers": "^3.2.1",
|
||||
|
@ -353,7 +353,7 @@
|
|||
"regenerator-runtime": {
|
||||
"version": "0.11.1",
|
||||
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
|
||||
"integrity": "sha1-vgWtf5v30i4Fb5cmzuUBf78Z4uk="
|
||||
"integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg=="
|
||||
},
|
||||
"setimmediate": {
|
||||
"version": "1.0.5",
|
||||
|
@ -386,7 +386,7 @@
|
|||
"ua-parser-js": {
|
||||
"version": "0.7.17",
|
||||
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.17.tgz",
|
||||
"integrity": "sha1-6exflJi57JEOeuOsYmqAXE0J7Kw="
|
||||
"integrity": "sha512-uRdSdu1oA1rncCQL7sCj8vSyZkgtL7faaw9Tc9rZ3mGgraQ7+Pdx7w5mnOSF3gw9ZNG6oc+KXfkon3bKuROm0g=="
|
||||
},
|
||||
"uncontrollable": {
|
||||
"version": "4.1.0",
|
||||
|
|
Loading…
Reference in New Issue