<commit_before>import * as express from "express";
import { DbFacadeInterface } from "../db/db-facade";
import { Racer } from "../../common/racer";

export default function racersRouterWithDb(db_facade: DbFacadeInterface) {
  let racersRouter = express.Router();

  racersRouter.use(function(req, res, next) {
    console.log('Racers request');
    next();
  });

  racersRouter.get('/', function(req, res) {
    console.log('GET /racers'); 
    db_facade.getRacers()
      .then(racers => {
        res.type('application/json');
        res.send(JSON.stringify(racers));
      });
  })

  racersRouter.post('/', function(req, res) {
    console.log('POST /racers')
    let body = req.body;
    db_facade.createRacer(body)
      .then(newRacer => {
        res.type('application/json');
        res.send(JSON.stringify(newRacer));
      })
  })

  racersRouter.put('/:id', function(req, res) {
    console.log('PUT /racers')
    let body = req.body;
    console.log(body);
    let newDetailsRacer = Racer.fromJSON(body);

    db_facade.updateRacer(req.params.id, newDetailsRacer)
      .then(changedRacer => {
        res.type('application/json');
        res.send(JSON.stringify(changedRacer));
      });
  })
<commit_msg>Fix getting single racer details<commit_after>import * as express from "express";
import { DbFacadeInterface } from "../db/db-facade";
import { Racer } from "../../common/racer";

export default function racersRouterWithDb(db_facade: DbFacadeInterface) {
  let racersRouter = express.Router();

  racersRouter.use(function(req, res, next) {
    console.log('Racers request');
    next();
  });

  racersRouter.get('/', function(req, res) {
    console.log('GET /racers'); 
    db_facade.getRacers()
      .then(racers => {
        res.type('application/json');
        res.send(JSON.stringify(racers));
      });
  })

  racersRouter.get('/:id', (req, res) => {
    let id = req.params.id;
    db_facade.getRacer(id)
      .then(racer => {
        res.type('application/json');
        res.send(JSON.stringify(racer));
      });
  });

  racersRouter.post('/', function(req, res) {
    console.log('POST /racers')
    let body = req.body;
    db_facade.createRacer(body)
      .then(newRacer => {
        res.type('application/json');
        res.send(JSON.stringify(newRacer));
      })
  })

  racersRouter.put('/:id', function(req, res) {
    console.log('PUT /racers')
    let body = req.body;
    console.log(body);
    let newDetailsRacer = Racer.fromJSON(body);

    db_facade.updateRacer(req.params.id, newDetailsRacer)
      .then(changedRacer => {
        res.type('application/json');
        res.send(JSON.stringify(changedRacer));
      });
  })

{'fraction_non_alphanumeric': 0.16964951528709918, 'fraction_numerical': 0.0, 'mean_word_length': 2.986627043090639, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4650315', 'n_tokens_mistral': 913, 'n_tokens_neox': 897, 'n_words': 144}