<commit_before>var express = require('express')
	, bodyParser = require('body-parser')
	, expressValidator = require('express-validator')
	, log = require('npmlog')

	Cloud = require('vigour-js/browser/network/cloud')
    .inject(require('vigour-js/browser/network/cloud/datacloud'))
  , Data = require('vigour-js/data')
  , fs = require('vigour-fs')

  , spriteMaker = require('./spriteMaker')
  , imgManip = require('./imgManip')
  , util = require('./util')
  , setHeaders = require('./setHeaders')

	, config = require('./config')

	, cloud = new Cloud('ws://' + config.cloudHost + ':' + config.cloudPort)
	, data = new Data(cloud.data.get(config.mtvCloudDataFieldName))

	, subscribeObj = {}

Object.defineProperty(Error.prototype, 'toJSON', {
    value: function () {
        var alt = {}

        Object.getOwnPropertyNames(this).forEach(function (key) {
            alt[key] = this[key]
        }, this)

        return alt
    },
    configurable: true
})

cloud.on('welcome', function (err) {
	log.info('cloud welcome')
})

cloud.on('error', function (err) {
	log.error('cloud error', err)
})

subscribeObj[config.mtvCloudDataFieldName] =  {
	// regions: {
		// $: {
		// 	$: {
		'Netherlands': { // Only use Netherlands until the cloud can support more
			$: {	// Only use en until the cloud can support more
				shows: {
					$: {
						img: true
						, number: true
						, seasons: {
							$: {
								number: true
								, episodes: {
									$: {
										img: true
										, number: true
									}
								}
							}
						}
					}
				},
				channels: {
					$: {
						img: true
						, number: true
					}
				}
			}
		}
	// }
}

cloud.subscribe(subscribeObj)

app = express();

app.use(function (req, res, next) {
	log.info(req.method, req.originalUrl)
	next()
})

app.use(bodyParser.urlencoded({
	extended: true
}))
app.use(expressValidator())

function serveCached (req, res, next) {
	var filePath = req.out + '.jpg'
	serveIfExists(filePath
		, req.cacheForever
		, res
		, function (err) {
			if (err) {
				filePath = req.out + '.png'
				serveIfExists(filePath
					, req.cachedForever
					, res
					, function (err) {
						if (err) {<commit_msg>Listen to all countries<commit_after>var express = require('express')
	, bodyParser = require('body-parser')
	, expressValidator = require('express-validator')
	, log = require('npmlog')

	Cloud = require('vigour-js/browser/network/cloud')
    .inject(require('vigour-js/browser/network/cloud/datacloud'))
  , Data = require('vigour-js/data')
  , fs = require('vigour-fs')

  , spriteMaker = require('./spriteMaker')
  , imgManip = require('./imgManip')
  , util = require('./util')
  , setHeaders = require('./setHeaders')

	, config = require('./config')

	, cloud = new Cloud('ws://' + config.cloudHost + ':' + config.cloudPort)
	, data = new Data(cloud.data.get(config.mtvCloudDataFieldName))

	, subscribeObj = {}

log.info('Image server starting')

Object.defineProperty(Error.prototype, 'toJSON', {
    value: function () {
        var alt = {}

        Object.getOwnPropertyNames(this).forEach(function (key) {
            alt[key] = this[key]
        }, this)

        return alt
    },
    configurable: true
})

cloud.on('welcome', function (err) {
	log.info('cloud welcome')
})

cloud.on('error', function (err) {
	log.error('cloud error', err)
})

subscribeObj[config.mtvCloudDataFieldName] =  {
	$: {
		$: {
			shows: {
				$: {
					img: true
					, number: true
					, seasons: {
						$: {
							number: true
							, episodes: {
								$: {
									img: true
									, number: true
								}
							}
						}
					}
				}
			},
			channels: {
				$: {
					img: true
					, number: true
				}
			}
		}
	}
}

cloud.subscribe(subscribeObj)

app = express();

app.use(function (req, res, next) {
	log.info(req.method, req.originalUrl)
	next()
})

app.use(bodyParser.urlencoded({
	extended: true
}))
app.use(expressValidator())

function serveCached (req, res, next) {
	var filePath = req.out + '.jpg'
	serveIfExists(filePath
		, req.cacheForever
		, res
		, function (err) {
			if (err) {
				filePath = req.out + '.png'
				serveIfExists(filePath
					, req.cachedForever
					, res
					, function (err) {
						if (err) {
{'fraction_non_alphanumeric': 0.16394606103619588, 'fraction_numerical': 0.0, 'mean_word_length': 2.5830508474576273, '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': '2687389', 'n_tokens_mistral': 1733, 'n_tokens_neox': 1423, 'n_words': 266}