<commit_before>const router = require('express').Router();
const checkValidRequest = require('../middlewares/valid-request');
const Day = require('../models/day');
const { createSelector } = require('../models/day');

router.get('/', checkValidRequest, (req, res, next) => {
  const { day: intDay, month: intMonth, type, short } = req.query;

  Day
    .findOne({ day: intDay, month: intMonth }, createSelector(type, short))
    .then((day) => {
      if (day) {
        res.status(200).json(day);
      } else {
        next({ message: 'Day not found', statusCode: 404 });
      }
    })
    .catch(next);
});

module.exports = router;
<commit_msg>refactor: use async/await in episodes route<commit_after>const router = require('express').Router();
const checkValidRequest = require('../middlewares/valid-request');
const Day = require('../models/day');
const { createSelector } = require('../models/day');

router.get('/', checkValidRequest, async (req, res, next) => {
  const { day: intDay, month: intMonth, type, short } = req.query;

  try {
    const day = await Day.findOne({ day: intDay, month: intMonth }, createSelector(type, short));
    if (day) {
      res.status(200).json(day);
    } else {
      next({ message: 'Day not found', statusCode: 404 });
    }
  } catch (error) {
    next(error);
  }
});

module.exports = router;

{'fraction_non_alphanumeric': 0.18317200297840655, 'fraction_numerical': 0.008935219657483246, 'mean_word_length': 3.51006711409396, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '6855447', 'n_tokens_mistral': 429, 'n_tokens_neox': 417, 'n_words': 106}