<commit_before>#### Routes
# We are setting up theese routes:
#
# GET, POST, PUT, DELETE methods are going to the same controller methods - we dont care.
# We are using method names to determine controller actions for clearness.


module.exports  = (app) ->
  #   - _/_ -> controllers/index/index method
  app.all '/', (req, res, next)->
    routeMvc('index', 'index', req, res, next)

  #   - _/**:controller**_  -> controllers/***:controller***/index method
  app.all '/:controller' , (req, res, next)->
    routeMvc(req.params.controller, 'index',req,res, next)

  #   - _/**:controller**/**:method**_ -> controllers/***:controller***/***:method*** method
  app.all '/:controller/:method' , (req, res, next)->
    routeMvc(req.params.controller, req.params.method, req,res,next)

  #   - _/**:controller**/**:method**/**:id**_ -> controllers/***:controller***/***:method*** method with ***:id*** param passed
  app.all '/:controller/:method/:id' , (req, res, next)->
    routeMvc(req.params.controller, req.params.method,req,res, next)

  # If all else failed, show 404 page
  app.all '/*', (req, res)->
    console.warn "error 404: ", req.url
    res.statusCode = 404
    res.render '404', 404

# render the page based on controller name, method and id
routeMvc = (controllerName, methodName, req, res, next)->
  controllerName='index' if not controllerName?
  controller=null
  try
    controller=require "./controllers/"+controllerName
  catch e
    console.warn "controller not found: "+ controllerName, e
    next()
    return
  data=null
  if typeof controller[methodName] is 'function'
    actionMethod = controller[methodName].bind controller
    actionMethod req, res, next
  else
    console.warn 'method not found: ' +methodName
    next()<commit_msg>format routes to match rest of codebase<commit_after>#### Routes
# We are setting up theese routes:
#
# GET, POST, PUT, DELETE methods are going to the same controller methods - we dont care.
# We are using method names to determine controller actions for clearness.


module.exports = (app) ->
  #   - _/_ -> controllers/index/index method
  app.all '/', (req, res, next) ->
    routeMvc('index', 'index', req, res, next)

  #   - _/**:controller**_  -> controllers/***:controller***/index method
  app.all '/:controller' , (req, res, next) ->
    routeMvc(req.params.controller, 'index',req,res, next)

  #   - _/**:controller**/**:method**_ -> controllers/***:controller***/***:method*** method
  app.all '/:controller/:method' , (req, res, next) ->
    routeMvc(req.params.controller, req.params.method, req,res,next)

  #   - _/**:controller**/**:method**/**:id**_ -> controllers/***:controller***/***:method*** method with ***:id*** param passed
  app.all '/:controller/:method/:id' , (req, res, next) ->
    routeMvc(req.params.controller, req.params.method,req,res, next)

  # If all else failed, show 404 page
  app.all '/*', (req, res) ->
    console.warn "error 404: ", req.url
    res.statusCode = 404
    res.render '404', 404

# render the page based on controller name, method and id
routeMvc = (controllerName, methodName, req, res, next) ->
  controllerName = 'index' if not controllerName?
  controller = null
  try
    controller = require "./controllers/" + controllerName
  catch e
    console.warn "controller not found: " + controllerName, e
    next()
    return
  data=null
  if typeof controller[methodName] is 'function'
    actionMethod = controller[methodName].bind controller
    actionMethod req, res, next
  else
    console.warn 'method not found: ' + methodName
    next()
{'fraction_non_alphanumeric': 0.16465975917110054, 'fraction_numerical': 0.008401008120974517, 'mean_word_length': 3.7248677248677247, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '2082883', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1078, 'n_words': 323}