<commit_before>/**
 * Server
 * ======
 *
 * Webserver handling the routes.
 */

import Hapi from 'hapi'

import digimeo from './services/digimeo'
import lyrics from './services/lyrics'
import acoustid from './services/acoustid'
import mooma from './services/mooma'

import config from './config'

var server = new Hapi.Server({/** options **/})

server.connection(config.server)

server.register([], function (err) {
  if (err) {
    throw err
  }

  server.route({
    method: 'GET',
    path: '/text/lyrics/{text}',
    handler (req, reply) {
      // lyrics(req.params.text).then(digimeo).then((suggestions) => reply(suggestions))
      lyrics(req.params.text).then(digimeo).then(reply)
    }
  })

  server.route({
    method: 'GET',
    path: '/audio/chromaprint/{code}',
    handler (req, reply) {
      // acoustid(req.params.code).then(digimeo).then((suggestions) => reply(suggestions))
      acoustid(req.params.code).then(digimeo).then(reply)
    }
  })

  server.route({
    method: 'GET',
    path: '/text/echoprint/{code}',
    handler (req, reply) {
      // mooma(req.params.code).then(digimeo).then((suggestions) => reply(suggestions))
      mooma(req.params.code).then(digimeo).then(reply)
    }
  })

  server.start(() => console.log('[SERVER] - %s', config.server.address || server.info.uri))
})<commit_msg>add error handler<commit_after>/**
 * Server
 * ======
 *
 * Webserver handling the routes.
 */

import Hapi from 'hapi'

import digimeo from './services/digimeo'
import lyrics from './services/lyrics'
import acoustid from './services/acoustid'
import mooma from './services/mooma'

import config from './config'

var server = new Hapi.Server({/** options **/})

server.connection(config.server)

server.register([], function (err) {
  if (err) {
    throw err
  }

  server.route({
    method: 'GET',
    path: '/text/lyrics/{text}',
    handler (req, reply) {
      lyrics(req.params.text)
        .then(digimeo)
          .then(reply)
          .catch(reply)
    }
  })

  server.route({
    method: 'GET',
    path: '/audio/chromaprints/{code}',
    handler (req, reply) {
      acoustid(req.params.code)
        .then(digimeo)
          .then(reply)
          .catch(reply)
    }
  })

  server.route({
    method: 'GET',
    path: '/audio/echoprints/{code}',
    handler (req, reply) {
      mooma(req.params.code)
        .then(digimeo)
          .then(reply)
          .catch(reply)
    }
  })

  server.start(() => console.log('[SERVER] - %s', config.server.address || server.info.uri))
})
{'fraction_non_alphanumeric': 0.18099009900990098, 'fraction_numerical': 0.0, 'mean_word_length': 2.8447488584474887, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '7403782', 'n_tokens_mistral': 879, 'n_tokens_neox': 866, 'n_words': 167}