<commit_before>import express from 'express'
import React from 'react'
import Router from 'react-router'
import {Resolver} from 'react-resolver'

import routes from 'routes'
import alt from 'alt-instance'

const app = express()

app.set('view engine', 'ejs')

app.use('/public', express.static('public'))

app.use((req, res) => {
  // react-router handler
  Router.run(routes, req.url, (Handler, state) => {
    const logLabel = `react server render: ${req.method} -- ${req.url}`
    console.time(logLabel)
    Resolver.resolve(() => <Handler {...state} />)
            .then(({Resolved, data}) => {
              // React renders the component
              const content = React.renderToString(<Resolved />)
              const __alt_data = alt.flush()


              // Make sure the right status is set when we hit <NotFoundRoute />
              if (state.routes[0].isNotFound) res.status(404)

              // Use ejs template (./views/index.ejs)
              res.render('index', {
                content: content,
                __alt_data: __alt_data,
                __react_resolver_data: data
              })

              // Very minimal logging
              console.timeEnd(logLabel)
            })
            .catch((e) => {
              console.error(e.stack)
              res.status(500).send(e.stack)
              console.timeEnd(logLabel)
            })
  })
})

const server = app.listen(process.env.PORT || 3000, () => {
  const [host, port] = [server.address().address, server.address().port]
  console.log(`Server listening on http://${host}:${port}`)
})<commit_msg>Display the whole error object if there is no stack prop<commit_after>import express from 'express'
import React from 'react'
import Router from 'react-router'
import {Resolver} from 'react-resolver'

import routes from 'routes'
import alt from 'alt-instance'

const app = express()

app.set('view engine', 'ejs')

app.use('/public', express.static('public'))

app.use((req, res) => {
  // react-router handler
  Router.run(routes, req.url, (Handler, state) => {
    const logLabel = `react server render: ${req.method} -- ${req.url}`
    console.time(logLabel)
    Resolver.resolve(() => <Handler {...state} />)
            .then(({Resolved, data}) => {
              // React renders the component
              const content = React.renderToString(<Resolved />)
              const __alt_data = alt.flush()


              // Make sure the right status is set when we hit <NotFoundRoute />
              if (state.routes[0].isNotFound) res.status(404)

              // Use ejs template (./views/index.ejs)
              res.render('index', {
                content: content,
                __alt_data: __alt_data,
                __react_resolver_data: data
              })

              // Very minimal logging
              console.timeEnd(logLabel)
            })
            .catch((e) => {
              const disp = e.stack ? e.stack : e
              console.error(disp)
              res.status(500).send(disp)
              console.timeEnd(logLabel)
            })
  })
})

const server = app.listen(process.env.PORT || 3000, () => {
  const [host, port] = [server.address().address, server.address().port]
  console.log(`Server listening on http://${host}:${port}`)
})
{'fraction_non_alphanumeric': 0.1433353621424224, 'fraction_numerical': 0.006695069993913573, 'mean_word_length': 2.092191909689558, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, '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': '4841620', 'n_tokens_mistral': 957, 'n_tokens_neox': 926, 'n_words': 233}