Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mod: config yaml #35

Merged
merged 1 commit into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ proxy:
prometheus:
target: "192.168.8.157:9090"
nebulaServer:
ip: "192.168.8.145",
ip: "192.168.8.145"
port: 9669

24 changes: 19 additions & 5 deletions server/dev-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@ import webpackDevMiddleware from 'webpack-dev-middleware';
import { createProxyMiddleware } from 'http-proxy-middleware';
import history from 'connect-history-api-fallback';
import fs from 'fs';
import path from 'path';

import path from "path";
const yaml = require('js-yaml');
import config from '../config/webpack.config.dev';
import pkg from '../package.json';

let _config = {} as any;
try {
let fileContents = fs.readFileSync(path.join(__dirname, './config.yaml'), 'utf8');
_config = yaml.load(fileContents);
} catch (e) {
console.log(e);
throw new Error();
}

const app = express();
const compiler = webpack(config);
const { nebulaServer } = _config;

app.use(history());

Expand Down Expand Up @@ -44,11 +54,15 @@ app.get('/api/app', (_req, res) => {
});

app.get('/api/config/custom', async (_req, res) => {
const data = await fs.readFileSync(path.join(__dirname, '../static/custom.json'), 'utf8');
if (data) {
if (nebulaServer) {
res.send({
code: 0,
data: JSON.parse(data)
data: {
connection: nebulaServer,
alias: {
"ip:port": "instance1"
},
}
});
} else {
res.send({
Expand Down
4 changes: 2 additions & 2 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const pkg = require('../package.json');
const yaml = require('js-yaml');
let config = {};
try {
let fileContents = fs.readFileSync('config.yaml', 'utf8');
let fileContents = fs.readFileSync(path.join(__dirname, './config.yaml'), 'utf8');
config = yaml.load(fileContents);
} catch (e) {
console.log(e);
Expand Down Expand Up @@ -56,7 +56,7 @@ app.get('/api/app', (_req, res) => {
});

app.get('/api/config/custom', async (_req, res) => {
if (data) {
if (nebulaServer) {
res.send({
code: 0,
data: {
Expand Down