<commit_before>import express = require("express");
import Characters from '../models/characters';

let router: CharactersRoutes;
export default class CharactersRoutes {
  characters: Characters = null;

  constructor() {
    router = this;
    router.characters = new Characters();
  }

  all(req: any, res: any): void {
    console.log(router);
    if (req.query.startWith) {
      router.characters.getStartingBy(req.query.startWith)
        .then(characters => res.json(characters))
        .catch(err => res.send(err));
    } else {
      router.characters.getAll()
        .then(characters => res.json(characters))
        .catch(err => res.send(err));
    }
  }

  byId(req: any, res: any): void {
    router.characters.getById(req.params.marvelId)
      .then(character => res.json(character))
      .catch(err => res.send(err));
  };
};<commit_msg>Add comics to characters detail endpoint<commit_after>import express = require("express");
import Characters from '../models/characters';
import Comics from '../models/comics';

let router: CharactersRoutes;
export default class CharactersRoutes {
  characters: Characters = null;
  comics: Comics = null;


  constructor() {
    router = this;
    router.characters = new Characters();
    router.comics = new Comics();
  }

  all(req: any, res: any): void {
    console.log(router);
    if (req.query.startWith) {
      router.characters.getStartingBy(req.query.startWith)
        .then(characters => res.json(characters))
        .catch(err => res.send(err));
    } else {
      router.characters.getAll()
        .then(characters => res.json(characters))
        .catch(err => res.send(err));
    }
  }

  byId(req: any, res: any): void {
    const characterId = req.params.marvelId;
    router.characters.getById(characterId)
      .then(character => {
        const result = character;
        router.comics.getAllByCharacters(characterId)
          .then(comics => {
            result.comics = comics;
            res.json(result);
          })
          .catch(err => res.send(err));
      })
      .catch(err => res.send(err));
  };
};
{'fraction_non_alphanumeric': 0.1460513796384396, 'fraction_numerical': 0.0, 'mean_word_length': 2.8446069469835464, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '4977835', 'n_tokens_mistral': 665, 'n_tokens_neox': 652, 'n_words': 131}