add vars.js.template,
use vars config items in api
This commit is contained in:
parent
e133971911
commit
85d57b361b
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
**/package-lock.json
|
**/package-lock.json
|
||||||
**/node_modules
|
**/node_modules
|
||||||
|
**/vars.js
|
11
index.js
11
index.js
@ -6,7 +6,8 @@ const helmet = require("helmet");
|
|||||||
const morgan = require("morgan");
|
const morgan = require("morgan");
|
||||||
const https = require("https");
|
const https = require("https");
|
||||||
var package = require("./package.json");
|
var package = require("./package.json");
|
||||||
const { request } = require("http");
|
|
||||||
|
const {pveAPI, listenPort} = require("./vars.js")
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use(helmet());
|
app.use(helmet());
|
||||||
@ -55,10 +56,8 @@ function checkAuth (cookies, callback, vmpath = null) {
|
|||||||
|
|
||||||
function requestPVE (path, method, cookies, callback, body = null, token = null) {
|
function requestPVE (path, method, cookies, callback, body = null, token = null) {
|
||||||
let prms = new URLSearchParams(body);
|
let prms = new URLSearchParams(body);
|
||||||
|
let url = `${pveAPI}${path}`;
|
||||||
let content = {
|
let content = {
|
||||||
hostname: "pve.tronnet.net",
|
|
||||||
port: 443,
|
|
||||||
path: `/api2/json${path}`,
|
|
||||||
method: method,
|
method: method,
|
||||||
mode: "cors",
|
mode: "cors",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
@ -84,7 +83,7 @@ function requestPVE (path, method, cookies, callback, body = null, token = null)
|
|||||||
headers: ''
|
headers: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
const request = https.request(content);
|
const request = https.request(url, content);
|
||||||
|
|
||||||
request.on('error', reject);
|
request.on('error', reject);
|
||||||
request.on('response', response => {
|
request.on('response', response => {
|
||||||
@ -109,6 +108,6 @@ function requestPVE (path, method, cookies, callback, body = null, token = null)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.listen(80, () => {
|
app.listen(listenPort, () => {
|
||||||
console.log("listening on port 80");
|
console.log("listening on port 80");
|
||||||
});
|
});
|
4
vars.js.template
Normal file
4
vars.js.template
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
const pveAPI = "";
|
||||||
|
const listenPort = 80;
|
||||||
|
|
||||||
|
module.exports = {pveAPI, listenPort};
|
Loading…
Reference in New Issue
Block a user