mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 23:33:12 +09:00
Added fetch mod meta functionality
Fixed bug in settings with new UI Re-added mod nav options
This commit is contained in:
1 parent
1788d72f8f
commit
dc9d8bf987
5 files changed
+80
-21
No files matched your search
@@ -44,6 +44,7 @@ const bcrypt = require('bcryptjs');
|
||||
const crypto = require('crypto');
|
||||
const base64url = require('base64url');
|
||||
const moment = require("moment");
|
||||
const request = require("request")
|
||||
|
||||
// constants
|
||||
console.log(`Requiring config from ${args.config || './config'}`)
|
||||
@@ -644,6 +645,33 @@ app.get("/api/inventoryAsObject", function(req, res) {
|
||||
res.send(JSON.stringify(db.items));
|
||||
});
|
||||
|
||||
/**
|
||||
GET endpoint to read the masters inventory as an object with key:value pairs
|
||||
|
||||
@memberof clusterioMaster
|
||||
@instance
|
||||
@alias api/modData
|
||||
@returns {object} JSON
|
||||
*/
|
||||
|
||||
// wrap a request in an promise
|
||||
async function downloadPage(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
request(url, (error, response, body) => {
|
||||
resolve(body);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
app.get("/api/modmeta", async function(req, res) {
|
||||
endpointHitCounter.labels(req.route.path).inc();
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
let modData = await downloadPage("https://mods.factorio.com/api/mods/" + req.query.modname);
|
||||
res.send(modData);
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
POST endpoint for running commands on slaves.
|
||||
Requires x-access-token header to be set. Find you api token in secret-api-token.txt on the master (after running it once)
|
||||
|
||||
Reference in new issue
Block a user