DockerRestApi/routes/status.js
2019-09-19 20:23:48 +02:00

29 lines
No EOL
583 B
JavaScript

var express = require('express');
var router = express.Router();
var docker = require('../bin/dockerode');
router.get('/:id', (req, res, next) => {
if (req.params.id.startsWith("mc") == true) {
getContainer(req.params.id).then(data => {
res.send(data);
});
}
else {
res.send("not whitelisted");
}
});
function getContainer(containername) {
return new Promise((resolve, reject) => {
const container = docker.getContainer(containername);
container.inspect((err, data) => {
resolve({ err, data });
});
})
}
module.exports = router;