Skip to content

Commit 5c48b30

Browse files
committed
Separate backend from algorithm-visualizer repo
0 parents  commit 5c48b30

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1263
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/.idea
2+
/node_modules
3+
/npm-debug.log
4+
/public
5+
/pm2.config.js
6+
.DS_Store

.idea/encodings.xml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/server.iml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/webResources.xml

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

+266
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/backend.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const {
2+
__DEV__,
3+
backendBuildPath,
4+
} = require('../environment');
5+
6+
if (__DEV__) {
7+
const webpack = require('webpack');
8+
const webpackConfig = require('../webpack.backend.config.js');
9+
const compiler = webpack(webpackConfig);
10+
11+
let backend = null;
12+
let lastHash = null;
13+
compiler.watch({
14+
watchOptions: {
15+
ignored: /public/,
16+
},
17+
}, (err, stats) => {
18+
if (err) {
19+
lastHash = null;
20+
compiler.purgeInputFileSystem();
21+
console.error(err);
22+
} else if (stats.hash !== lastHash) {
23+
lastHash = stats.hash;
24+
console.info(stats.toString({
25+
cached: false,
26+
colors: true,
27+
}));
28+
29+
delete require.cache[require.resolve(backendBuildPath)];
30+
backend = require(backendBuildPath).default;
31+
}
32+
});
33+
34+
const backendWrapper = (req, res, next) => backend(req, res, next);
35+
backendWrapper.getHierarchy = () => backend.hierarchy;
36+
module.exports = backendWrapper;
37+
} else {
38+
const backend = require(backendBuildPath).default;
39+
const backendWrapper = (req, res, next) => backend(req, res, next);
40+
backendWrapper.getHierarchy = () => backend.hierarchy;
41+
module.exports = backendWrapper;
42+
}

0 commit comments

Comments
 (0)