<commit_before>root = exports ? this

express = require 'express'
validator = require('validator')

conf = require '../conf'
utils = require '../common/utils'
db = new (require '../common/database').Database(conf.db)
uiControllers = require './controllers/ui'
apiControllers = require './controllers/api'
AppError = require('../common/apperror').AppError

utils.log "Fora application started at #{new Date}"
utils.log "NODE_ENV is #{process.env.NODE_ENV}"

app = express()

app.use express.bodyParser({
    uploadDir:'../../www-user/temp',
    limit: '6mb'
})
app.use(express.limit('6mb'));


app.set("view engine", "hbs");
app.set('view options', { layout: conf.defaultViews.defaultLayout })

#static file handlers.
#app.use('/', express.static(__dirname + '/public/root'))
app.use('/public', express.static(__dirname + '/public'))
app.use(express.favicon());

app.use express.cookieParser()

#check for cross site scripting
app.use (req,res,next) =>
    for inputs in [req.params, req.query, req.body]
        if inputs
            for key, val of inputs
                val = inputs[key]
                if not /-html$/.test key
                    val = val.replace '<', '&lt;'
                    val = val.replace '>', '&gt;'                    
                inputs[key] = validator.sanitize(val).xss()
    next()

findHandler = (name, getHandler) ->
    controller = switch name.toLowerCase()        <commit_msg>Temp fix for removing __proto__ from request params<commit_after>root = exports ? this

express = require 'express'
validator = require('validator')

conf = require '../conf'
utils = require '../common/utils'
db = new (require '../common/database').Database(conf.db)
uiControllers = require './controllers/ui'
apiControllers = require './controllers/api'
AppError = require('../common/apperror').AppError

utils.log "Fora application started at #{new Date}"
utils.log "NODE_ENV is #{process.env.NODE_ENV}"

app = express()

app.use express.bodyParser({
    uploadDir:'../../www-user/temp',
    limit: '6mb'
})
app.use(express.limit('6mb'));


app.set("view engine", "hbs");
app.set('view options', { layout: conf.defaultViews.defaultLayout })

#static file handlers.
#app.use('/', express.static(__dirname + '/public/root'))
app.use('/public', express.static(__dirname + '/public'))
app.use(express.favicon());

app.use express.cookieParser()

#check for cross site scripting
app.use (req,res,next) =>
    for inputs in [req.params, req.query, req.body]
        if inputs
            for key, val of inputs
                val = inputs[key]
                if typeof(val) is 'string'
                    if not /-html$/.test key
                        val = val.replace '<', '&lt;'
                        val = val.replace '>', '&gt;'                    
                    inputs[key] = validator.sanitize(val).xss()
    next()

findHandler = (name, getHandler) ->
    controller = switch name.toLowerCase()        
{'fraction_non_alphanumeric': 0.16184971098265896, 'fraction_numerical': 0.0013600816048962938, 'mean_word_length': 2.762148337595908, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5691597', 'n_tokens_mistral': 880, 'n_tokens_neox': 874, 'n_words': 221}