mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 16:13:12 +09:00
webserver and API endpoint for getting network contents
This commit is contained in:
1 parent
fcb9c5add5
commit
8ea74821b4
1 file changed
+13
@@ -15,6 +15,10 @@ app.use(bodyParser.urlencoded({ extended: true }));
|
|||||||
|
|
||||||
// Set folder to serve static content from (the website)
|
// Set folder to serve static content from (the website)
|
||||||
app.use(express.static('static'));
|
app.use(express.static('static'));
|
||||||
|
// Set convenient paths to 3rd party libs like metroUI and jquery from their bower installs
|
||||||
|
// Use this to make it nice an easy to change without touching the HTML in production
|
||||||
|
app.use(express.static('bower_components/metro-dist'));
|
||||||
|
app.use(express.static('bower_components/jquery/dist'));
|
||||||
|
|
||||||
// set up database
|
// set up database
|
||||||
var Datastore = require('nedb');
|
var Datastore = require('nedb');
|
||||||
@@ -79,6 +83,15 @@ app.post("/remove", function(req, res) {
|
|||||||
// save items we get
|
// save items we get
|
||||||
db.items.removeitem(req.body, res);
|
db.items.removeitem(req.body, res);
|
||||||
});
|
});
|
||||||
|
// endpoint for getting an inventory of what we got
|
||||||
|
app.get("/inventory", function(req, res) {
|
||||||
|
res.header("Access-Control-Allow-Origin", "*");
|
||||||
|
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||||
|
// Check it and send it
|
||||||
|
db.items.find({}, function (err, docs) {
|
||||||
|
res.send(docs);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
var server = app.listen(config.masterPort || 8080, function () {
|
var server = app.listen(config.masterPort || 8080, function () {
|
||||||
console.log("Listening on port %s...", server.address().port);
|
console.log("Listening on port %s...", server.address().port);
|
||||||
|
|||||||
Reference in new issue
Block a user