2018-01-10 08:14:05 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
module.exports.create = function (cli, engine, dnsd) {
|
|
|
|
|
|
|
|
function runHttp() {
|
|
|
|
var path = require('path');
|
|
|
|
var express = require('express');
|
|
|
|
var app = express();
|
|
|
|
var httpServer = require('http').createServer(app);
|
|
|
|
|
|
|
|
app.use('/', express.static(path.join(__dirname, 'public')));
|
|
|
|
app.get('/api/peers', function (req, res) {
|
|
|
|
res.send({ nameservers: [] });
|
|
|
|
});
|
|
|
|
app.get('/api/zones', function (req, res) {
|
2018-01-10 08:25:56 +00:00
|
|
|
engine.zones.all(function (err, zones) {
|
2018-01-10 08:14:05 +00:00
|
|
|
res.send({ zones: zones });
|
|
|
|
});
|
|
|
|
});
|
|
|
|
app.get('/api/records/:zone', function (req, res) {
|
2018-01-10 08:25:56 +00:00
|
|
|
engine.records.all(function (err, records) {
|
2018-01-10 08:14:05 +00:00
|
|
|
res.send({ records: records });
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-01-10 08:25:56 +00:00
|
|
|
httpServer.listen(cli.http, function () {
|
|
|
|
console.log(httpServer.address().address + '#' + httpServer.address().port + ' (http)');
|
|
|
|
});
|
2018-01-10 08:14:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
runHttp();
|
|
|
|
|
|
|
|
};
|