digd.js/lib/httpd.js

32 lines
765 B
JavaScript
Raw Normal View History

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) {
engine.zones.all(function (zones) {
res.send({ zones: zones });
});
});
app.get('/api/records/:zone', function (req, res) {
engine.records.all(function (records) {
res.send({ records: records });
});
});
httpServer.listen(cli.http);
}
runHttp();
};