<commit_before>var async = require('async');
var utils = require('prana').utils;

var rest = module.exports;

/**
 * The route() hook.
 */
rest.route = function(routes, callback) {
  var application = this.application;
  var newRoutes = {};

  var self = this;
  async.each(Object.keys(this.application.types), function(typeName, next) {
    var typeModel = self.application.types[typeName];
    var type = typeModel.type;

    // Default path to type name.
    if (!type.path) {
      type.path = '/' + type.name;
    }

    // List or add items.
    newRoutes[type.path] = {
      access: true,
      callback: function(request, response, callback) {
        if (request.method == 'GET') {
          return typeModel.list(request.query, callback);
        }
        if (request.method == 'POST') {
          return typeModel.save(request.body, callback);
        }
        callback();
      }
    };

    // Get, update or delete an item.
    newRoutes[type.path + '/:' + type.name] = {
      access: true,
      callback: function(request, response, callback) {<commit_msg>Adding "/rest" prefix to REST endpoints.<commit_after>var async = require('async');
var utils = require('prana').utils;

var rest = module.exports;

/**
 * The route() hook.
 */
rest.route = function(routes, callback) {
  var application = this.application;
  var newRoutes = {};

  var self = this;
  async.each(Object.keys(this.application.types), function(typeName, next) {
    var typeModel = self.application.types[typeName];
    var type = typeModel.type;

    // Default path to type name.
    if (!type.path) {
      type.path = '/' + type.name;
    }

    // List or add items.
    newRoutes['/rest' + type.path] = {
      access: true,
      callback: function(request, response, callback) {
        if (request.method == 'GET') {
          return typeModel.list(request.query, callback);
        }
        if (request.method == 'POST') {
          return typeModel.save(request.body, callback);
        }
        callback();
      }
    };

    // Get, update or delete an item.
    newRoutes['/rest' + type.path + '/:' + type.name] = {
      access: true,
      callback: function(request, response, callback) {
{'fraction_non_alphanumeric': 0.14824920418371987, 'fraction_numerical': 0.0, 'mean_word_length': 2.5031847133757963, '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': '1778996', 'n_tokens_mistral': 671, 'n_tokens_neox': 663, 'n_words': 165}