<commit_before>import path from 'path'
import express from 'express'
import webpack from 'webpack'
import config from './webpack.dev.config'
import { addOauthRoute, fetchOauthToken } from './oauth'
import { updateStrings as updateTimeAgoStrings } from './src/lib/time_ago_in_words'
import httpProxy from 'http-proxy'

// load env vars first
require('dotenv').load({ silent: process.env.NODE_ENV === 'production' })
global.ENV = require('./env')

const app = express()
const compiler = webpack(config)
const proxy = httpProxy.createProxyServer({
  target: process.env.AUTH_DOMAIN,
  changeOrigin: true,
})

updateTimeAgoStrings({ about: '' })
addOauthRoute(app)

// Development Middleware
app.use(require('webpack-dev-middleware')(compiler, {
  noInfo: true,
  publicPath: config.output.publicPath,
}))
app.use(require('webpack-hot-middleware')(compiler))

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

// API Proxy
app.use('/api/v2', (req, res, next) => {
  // include root path in proxied request
  req.url = '/api/v2/' + req.url
  proxy.web(req, res, {})
})


// Main entry for app
app.get('/*', (req, res) => {
  res.sendFile(path.join(__dirname, './public/dev.html'))
})


// Catchall for any requests like /onboarding
app.get('*', (req, res) => {
  res.sendFile(path.join(__dirname, './public/dev.html'))
})

fetchOauthToken(() => {
  app.listen(6660, '0.0.0.0', (err) => {
    if (err) {
      console.log('Listen error', err)
      return<commit_msg>Proxy all /api requests (including /api/oauth).<commit_after>import path from 'path'
import express from 'express'
import webpack from 'webpack'
import config from './webpack.dev.config'
import { addOauthRoute, fetchOauthToken } from './oauth'
import { updateStrings as updateTimeAgoStrings } from './src/lib/time_ago_in_words'
import httpProxy from 'http-proxy'

// load env vars first
require('dotenv').load({ silent: process.env.NODE_ENV === 'production' })
global.ENV = require('./env')

const app = express()
const compiler = webpack(config)
const proxy = httpProxy.createProxyServer({
  target: process.env.AUTH_DOMAIN,
  changeOrigin: true,
})

updateTimeAgoStrings({ about: '' })
addOauthRoute(app)

// Development Middleware
app.use(require('webpack-dev-middleware')(compiler, {
  noInfo: true,
  publicPath: config.output.publicPath,
}))
app.use(require('webpack-hot-middleware')(compiler))

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

// API Proxy
app.use('/api/', (req, res, next) => {
  // include root path in proxied request
  req.url = '/api/' + req.url
  proxy.web(req, res, {})
})


// Main entry for app
app.get('/*', (req, res) => {
  res.sendFile(path.join(__dirname, './public/dev.html'))
})


// Catchall for any requests like /onboarding
app.get('*', (req, res) => {
  res.sendFile(path.join(__dirname, './public/dev.html'))
})

fetchOauthToken(() => {
  app.listen(6660, '0.0.0.0', (err) => {
    if (err) {
      console.log('Listen error', err)
      return
{'fraction_non_alphanumeric': 0.17766830870279146, 'fraction_numerical': 0.005911330049261084, 'mean_word_length': 4.372134038800706, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5123442', 'n_tokens_mistral': 1026, 'n_tokens_neox': 1015, 'n_words': 236}