<commit_before>const express = require('express');
const bodyParser = require('body-parser');
const mongoose = require('./db/mongoose');
const { ObjectID } = require('mongodb');

const Todo = require('./models/todo');

const app = express();
const port = process.env.PORT || 3000;

app.use(bodyParser.json());

app.post('/todos', (req, res) => {
  const { text } = req.body;
  const todo = new Todo({
    text
  });

  todo.save()
    .then((doc) => {
      res.send(doc);
    })
    .catch((error) => {
      res.status(400).send(error);
    });
});

app.get('/todos', (req, res) => {
  Todo.find()
    .then((todos) => {
      res.send({ todos });
    })
    .catch((error) => {
      res.status(400).send(error);
    });
});

app.get('/todos/:id', (req, res) => {
  const { id } = req.params;

  if (!ObjectID.isValid(id)) {
    return res.status(404).send();
  }

  Todo.findById(id)
    .then((todo) => {
      if (!todo) {
        return res.status(404).send();
      }
      res.send({ todo });
    })
    .catch((error) => {
      res.status(400).send();
    });
});

app.listen(port, () => {
  console.log(`Started on port ${port}`);
});

module.exports = app;<commit_msg>Add DELETE /todos/:id<commit_after>const express = require('express');
const bodyParser = require('body-parser');
const mongoose = require('./db/mongoose');
const { ObjectID } = require('mongodb');

const Todo = require('./models/todo');

const app = express();
const port = process.env.PORT || 3000;

app.use(bodyParser.json());

app.post('/todos', (req, res) => {
  const { text } = req.body;
  const todo = new Todo({
    text
  });

  todo.save()
    .then((doc) => {
      res.send(doc);
    })
    .catch((error) => {
      res.status(400).send(error);
    });
});

app.get('/todos', (req, res) => {
  Todo.find()
    .then((todos) => {
      res.send({ todos });
    })
    .catch((error) => {
      res.status(400).send(error);
    });
});

app.get('/todos/:id', (req, res) => {
  const { id } = req.params;

  if (!ObjectID.isValid(id)) {
    return res.status(404).send();
  }

  Todo.findById(id)
    .then((todo) => {
      if (!todo) {
        return res.status(404).send();
      }
      res.send({ todo });
    })
    .catch((error) => {
      res.status(400).send();
    });
});

app.delete('/todos/:id', (req, res) => {
  const { id } = req.params;

  if (!ObjectID.isValid(id)) {
    return res.status(404).send();
  }
  
  Todo.findByIdAndRemove(id)
    .then((todo) => {
      if (!todo) {
        return res.status(404).send();
      }
      res.send({ todo });
    })
    .catch((error) => {
      res.status(404).send();
    });
});

app.listen(port, () => {
  console.log(`Started on port ${port}`);
});

module.exports = app;
{'fraction_non_alphanumeric': 0.23324789454412304, 'fraction_numerical': 0.01720981325521787, 'mean_word_length': 2.594736842105263, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 26, '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': '2708434', 'n_tokens_mistral': 1045, 'n_tokens_neox': 1015, 'n_words': 171}