<commit_before>const Doctor = require('./doctor'),
    Serial = require('./serial'),
    Writer = require('./writer'),
    Director = require('./director'),
    Season = require('./season');

const processSuccessfulQueryResults = function(res) {
    return function (value) {
        res.send(value);
    }
}

const processFailedQueryResults = function(res) {
    return function (reason) {
        res.status(404).send('Error');
    }
}

/**
 * Set up routes and handlers for the v1 REST API
 * @param server {object} Restify server object
 */
module.exports.init = function (server, connection) {

    /**
     * @api {get} /doctors Retrieve all Doctors
     * @apiName GetDoctors
     * @apiGroup Doctor
     * 
     * @apiSuccess {Object[]} doctors List of Doctors.
     */
    server.get('/doctors', allDoctorsV1);
    server.get('/v1/doctors', allDoctorsV1);
    function allDoctorsV1(req, res) {
        Doctor.all(connection).then(processSuccessfulQueryResults(res), processFailedQueryResults(res));
    }

    /**
     * @api {get} /doctors/:id Retrieve a single Doctor
     * @apiName GetDoctor
     * @apiGroup Doctor<commit_msg>Arrow functions! #yak-shaving<commit_after>const Doctor = require('./doctor'),
    Serial = require('./serial'),
    Writer = require('./writer'),
    Director = require('./director'),
    Season = require('./season');

const processSuccessfulQueryResults = (res) => {
    return function (value) {
        res.send(value);
    }
}

const processFailedQueryResults = (res) => {
    return function (reason) {
        res.status(404).send('Error');
    }
}

/**
 * Set up routes and handlers for the v1 REST API
 * @param server {object} Restify server object
 */
module.exports.init = function (server, connection) {

    /**
     * @api {get} /doctors Retrieve all Doctors
     * @apiName GetDoctors
     * @apiGroup Doctor
     * 
     * @apiSuccess {Object[]} doctors List of Doctors.
     */
    server.get('/doctors', allDoctorsV1);
    server.get('/v1/doctors', allDoctorsV1);
    function allDoctorsV1(req, res) {
        Doctor.all(connection).then(processSuccessfulQueryResults(res), processFailedQueryResults(res));
    }

    /**
     * @api {get} /doctors/:id Retrieve a single Doctor
     * @apiName GetDoctor
     * @apiGroup Doctor
{'fraction_non_alphanumeric': 0.14391951006124235, 'fraction_numerical': 0.00699912510936133, 'mean_word_length': 3.0549645390070923, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2585245', 'n_tokens_mistral': 693, 'n_tokens_neox': 671, 'n_words': 163}