blinky/libs/index.js

72 lines
2.1 KiB
JavaScript
Raw Permalink Normal View History

const packageJSON = require('../package.json');
const config = require('../config.json');
function get() {
let html =
'<html>' +
'<head>' +
'<title>' + packageJSON.name + ' ' + packageJSON.version + '</title>' +
'<style>' +
'body { background: #2a2a2a; color: #f1f1f1; margin: 1.25% }' +
'th, td { border: 1px solid #919191; padding: 6px; text-align: left }' +
'</style>' +
'</head>' +
'<body>' +
'<div>' +
'<h1>' + packageJSON.name + ' ' + packageJSON.version + '</h1>' +
'</div>' +
'<hr>';
html +=
'<div>' +
'<h2>get:</h2>' +
'<p>' + config.api.get.description + '</p>' +
'<h3>endpoints: </>';
for (let index = 0; index < config.api.get.endpoints.length; index++) {
if (index > 0) {
html += ', ';
}
html += config.api.get.endpoints[index];
}
html +=
'</div>' +
'<div>' +
'<h2>post:</h2>' +
'<h3>endpoints: </>';
for (let index = 0; index < config.api.post.endpoints.length; index++) {
if (index > 0) {
html += ', ';
}
html += config.api.post.endpoints[index];
}
html += '</h3>' +
'<table style=\'width:100%\'>' +
'<th>argument</th>' +
'<th>available values</th>' +
'<th>default</th>' +
'<th>restrictions</th>' +
'<th>description</th>';
Object.keys(config.api.post).forEach((argument) => {
if (argument === 'endpoints') {
return;
}
let restrictions = config.api.post[argument].restrictions || '';
html +=
'<tr>' +
'<td>' + argument + '</td>' +
'<td>' + config.api.post[argument].available + '</td>' +
'<td>' + config.api.post[argument].default + '</td>' +
'<td>' + restrictions + '</td>' +
'<td>' + config.api.post[argument].description + '</td>' +
'</tr>';
});
html +=
'</table>' +
'</div>' +
'</body>' +
'</html>';
return html;
}
module.exports = {
get
};