The source code for a public API that I run.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

33 lines
939 B

var restify = require('restify');
var throttle_settings = { burst: 100,
rate: 50,
ip: true}
var server = restify.createServer();
server.use(restify.queryParser());
server.use(restify.bodyParser());
server.use(restify.throttle(throttle_settings));
require('./bjcp')(server);
require('./time')(server);
server.get('/', function(req, res){
var answer = {};
answer.time = {
'/time': 'get the current date/time as JSON object',
'/time/epoch': 'get the current epoch time as string',
'/time/utc' : 'get the current UTC date/time as JSON object',
};
answer.bjcp = {
'/bjcp': 'get the current BJCP style guide as JSON object, to search style guide provide query string parameters' +
', example (/bjcp?id=28A, /bjcp?mouthfeel=tannin)',
};
res.writeHead(200, {
'Content-Type': 'application/javascript'
});
return res.end(JSON.stringify(answer));
});
server.listen(process.env.PORT || 8080);