<commit_before>/**
 * Created by dll on 15/10/11.
 */

var bookSearch = require("../service/book-search-service");

function search(req, res, next) {
    var isbn = req.query.isbn;
    if (!isbn) {
        res.status(400).send({
            message: "isbn is required."
        });
        return;
    }
    bookSearch.findByIsbn(isbn, function (err, data) {
        if (err) {
            res.send({
                code: 400,
                msg: "search book by isbn err"
            });
        } else {
            res.json(data);
        }<commit_msg>when book not exist , give a friendly result<commit_after>/**
 * Created by dll on 15/10/11.
 */

var bookSearch = require("../service/book-search-service");

function search(req, res, next) {
    var isbn = req.query.isbn;
    if (!isbn) {
        res.status(400).send({
            message: "isbn is required."
        });
        return;
    }
    bookSearch.findByIsbn(isbn, function (err, data) {
        if (err) {
            res.send({
                code: 400,
                msg: "search book by isbn err"
            });
        } else {
            if (data) {
                res.json(data);
            } else {
                res.status(404).send({
                    message:'the book not found'
                });
                return;
            }
        }
{'fraction_non_alphanumeric': 0.13432835820895522, 'fraction_numerical': 0.020149253731343283, 'mean_word_length': 1.3321739130434782, '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': '72161', 'n_tokens_mistral': 427, 'n_tokens_neox': 396, 'n_words': 98}