<commit_before>const bugsnag = require('@bugsnag/js')
const Koa = require('koa')
const router = require('koa-router')
const serve = require('koa-static')
const mount = require('koa-mount')
const { readFileSync } = require('fs')

const bugsnagClient = bugsnag(process.env.BUGSNAG_API_KEY)
bugsnagClient.use(require('@bugsnag/plugin-koa'))

const app = new Koa()
const { requestHandler, errorHandler } = bugsnagClient.getPlugin('koa')

app.use(requestHandler)

app.use(mount('/static', serve(`${__dirname}/static`)))

const index = readFileSync('./views/index.html', 'utf8')

app.use(
  router()
    .get('/', (ctx, next) => {
      ctx.body = index
    })
    .post('/crash', (ctx, next) => {
      setTimeout(() => { throw new Error('Oh no!') })
      return new Promise(() => {})
    })
    .post('/unhandled', (ctx, next) => {
      return Promise.reject(new Error('Invalid DSL syntax'))
    })
    .post('/handled', (ctx, next) => {
      ctx.bugsnag.notify(new Error('Could not connect to xyz service'))
      ctx.response.status = 503<commit_msg>refactor(examples): Update Koa app to work with V7 notifier<commit_after>const Bugsnag = require('@bugsnag/js')
const Koa = require('koa')
const router = require('koa-router')
const serve = require('koa-static')
const mount = require('koa-mount')
const { readFileSync } = require('fs')

Bugsnag.init(process.env.BUGSNAG_API_KEY)
Bugsnag.use(require('@bugsnag/plugin-koa'))

const app = new Koa()
const { requestHandler, errorHandler } = Bugsnag.getPlugin('koa')

app.use(requestHandler)

app.use(mount('/static', serve(`${__dirname}/static`)))

const index = readFileSync('./views/index.html', 'utf8')

app.use(
  router()
    .get('/', (ctx, next) => {
      ctx.body = index
    })
    .post('/crash', (ctx, next) => {
      setTimeout(() => { throw new Error('Oh no!') })
      return new Promise(() => {})
    })
    .post('/unhandled', (ctx, next) => {
      return Promise.reject(new Error('Invalid DSL syntax'))
    })
    .post('/handled', (ctx, next) => {
      ctx.bugsnag.notify(new Error('Could not connect to xyz service'))
      ctx.response.status = 503
{'fraction_non_alphanumeric': 0.18829636621047663, 'fraction_numerical': 0.004247286455875413, 'mean_word_length': 3.941724941724942, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '4968215', 'n_tokens_mistral': 723, 'n_tokens_neox': 715, 'n_words': 155}