Skip to content

Commit 2f94e0f

Browse files
committed
use cors and create new api for fetching configuration
1 parent ab8e04c commit 2f94e0f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

source/server.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const BugTracker = require('./bugtracker');
33
const bugtracker = new BugTracker('server');
44
const usageStatistics = require('./usage-statistics');
55
const express = require('express');
6+
const cors = require('cors')
67
const gitApi = require('./git-api');
78
const winston = require('winston');
89
const sysinfo = require('./sysinfo');
@@ -107,6 +108,7 @@ const noCache = (req, res, next) => {
107108
app.use(noCache);
108109

109110
app.use(require('body-parser').json());
111+
app.use(cors()); // we should consider to remove it when we complete this project
110112

111113
if (config.autoShutdownTimeout) {
112114
let autoShutdownTimeout;
@@ -270,6 +272,20 @@ app.get('/serverdata.js', (req, res) => {
270272
});
271273
});
272274

275+
app.get('/ungit/config', (req, res) => {
276+
sysinfo.getUserHash()
277+
.then((hash) => {
278+
const ungitConfig = {
279+
config,
280+
userHash: hash,
281+
version: config.ungitDevVersion,
282+
platform: os.platform(),
283+
pluginApiVersion: require('../package.json').ungitPluginApiVersion
284+
};
285+
res.send(JSON.stringify(ungitConfig));
286+
});
287+
});
288+
273289
app.get('/api/latestversion', (req, res) => {
274290
sysinfo.getUngitLatestVersion()
275291
.then((latestVersion) => {

0 commit comments

Comments
 (0)