<commit_before>import './Config'
import './ErrorHandler'
import './Paths'
import './ProviderCollection'
import './UrlGenerator'

import './Routing/Router'
import './Routing/RoutingProvider'

import './Routing/Extensions/RequestExtension'
import './Routing/Extensions/ResponseExtension'
import './Routing/Extensions/RouteExtension'

const Express = require('express/lib/express.js')

export class Grind {
	express = null
	_env = null

	config = null
	errorHandler = null
	paths = null
	routes = null
	url = null

	booted = false
	port = 3000
	providers = null

	constructor(parameters = { }) {
		RequestExtension()
		ResponseExtension()
		RouteExtension()

		this.express = Express()
		this.express.disable('etag')
		this.express._grind = this

		this._env = parameters.env

		const routerClass = parameters.routerClass || Router
		const configClass = parameters.configClass || Config
		const errorHandlerClass = parameters.errorHandlerClass || ErrorHandler
		const urlGeneratorClass = parameters.urlGeneratorClass || UrlGenerator
		const pathsClass = parameters.pathsClass || Paths

		const routingProvider = parameters.routingProvider || RoutingProvider
		routingProvider.priority = RoutingProvider.priority

		const parent = module.parent.parent === null ? module.parent : (
			module.parent.parent.parent === null ? module.parent.parent : module.parent.parent.parent
		)

		this.paths = new pathsClass(parent.filename)
		this.config = new configClass(this)
		this.routes = new routerClass(this)
		this.errorHandler = new errorHandlerClass(this)

		this.providers = new ProviderCollection
		this.providers.add(routingProvider)

		this.debug = this.config.get('app.debug', this.env() === 'local')
		this.port = parameters.port || process.env.NODE_PORT || this.config.get('app.port', 3000)

		this.url = new urlGeneratorClass(this)
	}

	env() {
		return this._env || process.env.NODE_ENV || 'local'
	}

	async boot() {
		if(this.booted) {
			return
		}

		this.providers.sort((a, b) => a.priority > b.priority ? -1 : 1)

		for(const provider of this.providers) {
			await provider(this)
		}

		this.booted = true
	}

	async listen(...args) {
		await this.boot()

		// Register error handler
		this.express.use((err, req, res, next) => {<commit_msg>Updated the `Grind` class to extends `EventEmitter`<commit_after>import './Config'
import './ErrorHandler'
import './Paths'
import './ProviderCollection'
import './UrlGenerator'

import './Routing/Router'
import './Routing/RoutingProvider'

import './Routing/Extensions/RequestExtension'
import './Routing/Extensions/ResponseExtension'
import './Routing/Extensions/RouteExtension'

const Express = require('express/lib/express.js')
const EventEmitter = require('events')

export class Grind extends EventEmitter {
	express = null
	_env = null

	config = null
	errorHandler = null
	paths = null
	routes = null
	url = null

	booted = false
	port = 3000
	providers = null

	constructor(parameters = { }) {
		RequestExtension()
		ResponseExtension()
		RouteExtension()

		super()

		this.express = Express()
		this.express.disable('etag')
		this.express._grind = this

		this._env = parameters.env

		const routerClass = parameters.routerClass || Router
		const configClass = parameters.configClass || Config
		const errorHandlerClass = parameters.errorHandlerClass || ErrorHandler
		const urlGeneratorClass = parameters.urlGeneratorClass || UrlGenerator
		const pathsClass = parameters.pathsClass || Paths

		const routingProvider = parameters.routingProvider || RoutingProvider
		routingProvider.priority = RoutingProvider.priority

		const parent = module.parent.parent === null ? module.parent : (
			module.parent.parent.parent === null ? module.parent.parent : module.parent.parent.parent
		)

		this.paths = new pathsClass(parent.filename)
		this.config = new configClass(this)
		this.routes = new routerClass(this)
		this.errorHandler = new errorHandlerClass(this)

		this.providers = new ProviderCollection
		this.providers.add(routingProvider)

		this.debug = this.config.get('app.debug', this.env() === 'local')
		this.port = parameters.port || process.env.NODE_PORT || this.config.get('app.port', 3000)

		this.url = new urlGeneratorClass(this)

		this.on('error', err => Log.error('EventEmitter error', err))
	}

	env() {
		return this._env || process.env.NODE_ENV || 'local'
	}

	async boot() {
		if(this.booted) {
			return
		}

		this.providers.sort((a, b) => a.priority > b.priority ? -1 : 1)

		for(const provider of this.providers) {
			await provider(this)
		}

		this.booted = true
	}

	async listen(...args) {
		await this.boot()

		// Register error handler
		this.express.use((err, req, res, next) => {
{'fraction_non_alphanumeric': 0.1252676659528908, 'fraction_numerical': 0.004282655246252677, 'mean_word_length': 4.132967032967033, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '5599566', 'n_tokens_mistral': 1503, 'n_tokens_neox': 1386, 'n_words': 325}