<commit_before>import express from 'express';
import handleRoutes from './handle-routes';
import config from './commons/config';
import connectDb from './commons/db';

const app = express();

handleRoutes(app);

// app.start = () => {
//   return connectDb()
//     .then(() => {
//       app.listen(config.app.port, config.app.host, () => {
//         console.log(`Example app listening on http://${config.app.host}:${config.app.port}!`);
//       });
//     })
//     .catch(() => process.exit());
// }

connectDb()
  .then(() => {
    app.listen(config.app.port, config.app.host, () => {
      console.log(`Example app listening on http://${config.app.host}:${config.app.port}!`);
      app.emit('started');
    });
  })
  .catch(() => process.exit());

export default app;
<commit_msg>Add error handler for express<commit_after>import express from 'express';
import handleRoutes from './handle-routes';
import config from './commons/config';
import connectDb from './commons/db';

const app = express();

handleRoutes(app);

app.use((err, req, res, next) => {
  console.error(err.stack);
  res.status(500).json({ error: 'Something failed!' });
  next();
});

// app.start = () => {
//   return connectDb()
//     .then(() => {
//       app.listen(config.app.port, config.app.host, () => {
//         console.log(`Example app listening on http://${config.app.host}:${config.app.port}!`);
//       });
//     })
//     .catch(() => process.exit());
// }

connectDb()
  .then(() => {
    app.listen(config.app.port, config.app.host, () => {
      console.log(`Example app listening on http://${config.app.host}:${config.app.port}!`);
      app.emit('started');
    });
  })
  .catch(() => process.exit());

export default app;

{'fraction_non_alphanumeric': 0.23032407407407407, 'fraction_numerical': 0.001736111111111111, 'mean_word_length': 2.9565217391304346, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, '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': '2428049', 'n_tokens_mistral': 556, 'n_tokens_neox': 557, 'n_words': 110}