<commit_before>var express = require('express')
var router = express.Router()
var Book = require('../models/book')

/* get the list of books */
router.get('/books', function (req, res, next) {
  res.send({ name: 'GET' })
})

/* create a new book */
router.post('/books', function (req, res, next) {
  Book.create(req.body, function (err, book) {
    if (err) {
      next(err)
    } else {
      res.json(book)
    }
  })
  /* or */
  // Book.create(req.body).then(function (err, book) {
  //   if (err) {
  //     console.log(err)
  //   } else {
  //     res.json(book)
  //   }
  // }).catch(next)
})

/* update book */
router.put('/books/:id', function (req, res, next) {
  res.send({ name: 'PUT' })
})

/* delete book */
router.delete('/books/:id', function (req, res, next) {
  res.send({ name: 'DELETE' })
})

module.exports = router<commit_msg>get books array<commit_after>var express = require('express')
var router = express.Router()
var Book = require('../models/book')

/* get the list of books */
router.get('/books', function (req, res, next) {
  Book.find(function (err, books) {
    if (err) {
      next(err)
    } else {
      res.json(books)
    }
  })
})

/* create a new book */
router.post('/books', function (req, res, next) {
  Book.create(req.body, function (err, book) {
    if (err) {
      next(err)
    } else {
      res.json(book)
    }
  })
  /* or */
  // Book.create(req.body).then(function (err, book) {
  //   if (err) {
  //     console.log(err)
  //   } else {
  //     res.json(book)
  //   }
  // }).catch(next)
})

/* update book */
router.put('/books/:id', function (req, res, next) {
  Book.findByIdAndUpdate(req.params.id, req.body, { new: true }, function (err, book) {
    if (err) {
      next(err)
    } else {
      res.json(book)
    }
  })
})

/* delete book */
router.delete('/books/:id', function (req, res, next) {
  Book.findByIdAndRemove(req.params.id, function (err, book) {
    if (err) {
      next(err)
    } else {
      res.json(book)
    }
  })
})

module.exports = router
{'fraction_non_alphanumeric': 0.20393120393120392, 'fraction_numerical': 0.0, 'mean_word_length': 2.4161073825503356, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3685855', 'n_tokens_mistral': 739, 'n_tokens_neox': 742, 'n_words': 165}