<commit_before>const Router = require('koa-router')
const register = require('../tasks/register')
const cancel = require('../tasks/cancel')

const router = new Router({
  prefix: '/students'
})

router.post('/register', async (ctx) => {
  const {username, password} = ctx.request.fields || {}
  if (!username || !password) {
    ctx.throw(400, 'Missing Arguments')
  }

  const [user, existed] = await register(username, password)

  ctx.body = {
    username: username,
    existed: existed
  }

  if (user) {
    ctx.body.message = 'Success'
    ctx.body.information = user.info.toObject()
  } else {
    ctx.body.message = 'Failure'
  }
})

router.post('/:username/cancel', async (ctx) => {
  const {username} = ctx.params

  const removed = await cancel(username)

  ctx.body = {
    username: username
  }

  ctx.res.statusCode = removed ? 200 : 400
})

exports.router = router
<commit_msg>slightly change the ctx field<commit_after>const Router = require('koa-router')
const register = require('../tasks/register')
const cancel = require('../tasks/cancel')

const router = new Router({
  prefix: '/students'
})

router.post('/register', async (ctx) => {
  const {username, password} = ctx.request.fields || {}
  if (!username || !password) {
    ctx.throw(400, 'Missing Arguments')
  }

  const [user, existed] = await register(username, password)

  ctx.body = {
    username: username
  }

  if (user) {
    ctx.body.message = 'Success'
    ctx.body.existed = existed
    ctx.body.information = user.info.toObject()
  } else {
    ctx.body.message = 'Failure'
  }
})

router.post('/:username/cancel', async (ctx) => {
  const {username} = ctx.params

  const removed = await cancel(username)

  ctx.body = {
    username: username
  }

  ctx.res.statusCode = removed ? 200 : 400
})

exports.router = router

{'fraction_non_alphanumeric': 0.15922865013774104, 'fraction_numerical': 0.009917355371900827, 'mean_word_length': 3.3653846153846154, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3349815', 'n_tokens_mistral': 605, 'n_tokens_neox': 576, 'n_words': 138}