<commit_before>import { Request, Response } from 'express';
import * as mailchimp from 'mailchimp-api';

const MC = new mailchimp.Mailchimp(process.env.MAILCHIMP_API_KEY);

export function createSubscription(req: Request, res: Response) {
  // TODO: Check user is already subscribed
  MC.lists.subscribe({
    id: process.env.MAILCHIMP_INTERESTED_LIST_ID,
    email: { email: req.body.email },
    merge_vars: { EMAIL: req.body.email },
    update_existing: true
  },
  _ => res.json('An email requesting your confirmation has been sent to the address you provided.'),
  err => {
    if (err.name === 'ValidationError') {
      res.status(400).json(err.error);
    } else {
      res.status(500).json('The server encountered an error.');
    }
  });
}<commit_msg>Refactor<commit_after>import { Request, Response } from 'express';
import { Mailchimp } from 'mailchimp-api';

const MC = new Mailchimp(process.env.MAILCHIMP_API_KEY);

export function createSubscription(req: Request, res: Response) {
  },
  _ => res.json('An email requesting your confirmation has been sent to the address you provided.'),
  err => {
    if (err.name === 'ValidationError') {
      res.status(400).json(err.error);
    } else {
      res.status(500).json('The server encountered an error.');
      // TODO: Check user is already subscribed
      MC.lists.subscribe({
        id: process.env.MAILCHIMP_INTERESTED_LIST_ID,
        email: { email: req.body.email },
        merge_vars: { EMAIL: req.body.email },
        update_existing: true
    }
  });
}
{'fraction_non_alphanumeric': 0.1316818774445893, 'fraction_numerical': 0.007822685788787484, 'mean_word_length': 3.4883040935672516, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4936734', 'n_tokens_mistral': 482, 'n_tokens_neox': 480, 'n_words': 121}