<commit_before>const router  = require("koa-router")();
const dao     = require("../dao/shortcut")();
const path    = "/shortcut";
const koaBody = require('koa-body')();

module.exports = function(server) {
  /**
   * @method create url
   * @param { url }
   * @uses post
   **/
  router.post( path , koaBody, function *(next){
    var data = yield dao.insertShortcut(this.request.body.url);
    this.body = { success: true , shortcut: data};
  });

  /**
   * @method get all
   * @uses get
   **/
  router.get( path + "s" , function *(next){
    var data = yield dao.getAllShortcuts();
    this.body = { success: true , shortcuts: data};
  });

  /**
   * @method read url by id
   * @uses get
   * This method redirets to the url described by the id
   **/
  router.get( path + "/:id" , function *(next){
    var data = yield dao.getShortcutById(this.params.id);
    this.redirect( data.url );
  });
  // direct access
  router.get( "/:id" , function *(next){
    var data = yield dao.getShortcutById(this.params.id);
    this.redirect( data.url );
  });
<commit_msg>webservices aligned with backbone-frontend MVC<commit_after>const router  = require("koa-router")();
const dao     = require("../dao/shortcut")();
const path    = "/shortcut";
const koaBody = require('koa-body')();

module.exports = function(server) {
  /**
   * @method create url
   * @param { url }
   * @uses post
   **/
  router.post( path , koaBody, function *(next){
    var data = yield dao.insertShortcut(this.request.body.url);
    this.body = data;
  });

  /**
   * @method get all
   * @uses get
   **/
  router.get( path , function *(next){
    var data = yield dao.getAllShortcuts();
    this.body = data;
  });

  /**
   * @method read url by id
   * @uses get
   * This method redirets to the url described by the id
   **/
  router.get( path + "/:id" , function *(next){
    var data = yield dao.getShortcutById(this.params.id);
    this.body = data;
  });

  // direct access
  router.get( "/:id" , function *(next){
    var data = yield dao.getShortcutById(this.params.id);
    this.redirect( data.url );
  });

{'fraction_non_alphanumeric': 0.170313986679353, 'fraction_numerical': 0.0, 'mean_word_length': 2.8236363636363637, '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': '6223660', 'n_tokens_mistral': 723, 'n_tokens_neox': 713, 'n_words': 185}