<commit_before>var Promise = require('bluebird');
var Post = require('../models/post');
var Comment = require('../models/comment');
var ExpiringToken = require('../models/expiringToken');
var access = require('./access');
var observer = require('../observer');

module.exports = function(app, passport) {

  /**
   * GET a comment.
   *
   * @param   comment id
   * @returns comment
   */

  app.get('/api/comments/:id',function(req, res, next) {
    Comment
      .findOne(req.params.id)
      .select('')
      .exec(function (err, model) {
        if (err) return next(err);
        if(!model) return res.send(404,"Not Found");
        res.json({
            comment: model<commit_msg>Adds GET all comments route<commit_after>var Promise = require('bluebird');
var Post = require('../models/post');
var Comment = require('../models/comment');
var ExpiringToken = require('../models/expiringToken');
var access = require('./access');
var observer = require('../observer');

module.exports = function(app, passport) {

  /**
   * GET All comments of specific query
   *
   * @param   query {optional}
   * @returns comments
   */

  app.get('/api/comments',function(req,res,next) {
    Comment.find({post:req.query.post})
        .select('')
        .exec()
        .then(function(model) {
          if (!model) return res.send(404, "Not Found");
          console.log(model);
          res.json({
              comments: model
          });
    }, next);
  });

  /**
   * GET a comment.
   *
   * @param   comment id
   * @returns comment
   */

  app.get('/api/comments/:id',function(req, res, next) {
    Comment
      .findOne(req.params.id)
      .select('')
      .exec(function (err, model) {
        if (err) return next(err);
        if(!model) return res.send(404,"Not Found");
        res.json({
            comment: model
{'fraction_non_alphanumeric': 0.17429193899782136, 'fraction_numerical': 0.004901960784313725, 'mean_word_length': 2.5057251908396947, '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': '2448453', 'n_tokens_mistral': 567, 'n_tokens_neox': 552, 'n_words': 128}