<commit_before>/* TODOs:
 *  - validate query parameters
 */

var restify = require('restify'),
    server = restify.createServer()

server.use(restify.queryParser())

// Number of sides, default is 6 
var sides = [4, 6, 8, 10, 12, 20, 30]

function roll (s, n) {
  var retval = {sum : 0, val: []}
  for(var i = 0; i < n; i++) {
    retval.val.push(Math.floor(Math.random() * s) + 1)
    retval.sum += retval.val[i]
  }
  return retval
}

server.get('/roll', function respond (req, res, next) {
  var s = req.params.s || 6 //number of sides
  var n = req.params.n || 3 //number of dice
  var r = req.params.r || 1 //number of rolls

  var retval = []
  for(var i = 0; i < r; i++) {
    retval.push(roll(s, n))
  }

  res.send(retval)
  next()
})

server.listen(8080, function() {
  console.log('%s listening at %s', server.name, server.url)
})<commit_msg>Set port number to 80<commit_after>/* TODOs:
 *  - validate query parameters
 */

var restify = require('restify'),
    server = restify.createServer()

server.use(restify.queryParser())

// Number of sides, default is 6 
var sides = [4, 6, 8, 10, 12, 20, 30]

function roll (s, n) {
  var retval = {sum : 0, val: []}
  for(var i = 0; i < n; i++) {
    retval.val.push(Math.floor(Math.random() * s) + 1)
    retval.sum += retval.val[i]
  }
  return retval
}

server.get('/roll', function respond (req, res, next) {
  var s = req.params.s || 6 //number of sides
  var n = req.params.n || 3 //number of dice
  var r = req.params.r || 1 //number of rolls

  var retval = []
  for(var i = 0; i < r; i++) {
    retval.push(roll(s, n))
  }

  res.send(retval)
  next()
})

server.listen(80, function() {
  console.log('%s listening at %s', server.name, server.url)
})
{'fraction_non_alphanumeric': 0.18181818181818182, 'fraction_numerical': 0.026806526806526808, 'mean_word_length': 2.9111617312072893, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4448240', 'n_tokens_mistral': 687, 'n_tokens_neox': 648, 'n_words': 194}