<commit_before>import {Router} from 'express'
const router = Router()

// define the home page route
router.post('/', (req, res) => {
  res.json({token: 'nothing'})
})

export default router<commit_msg>feat(src/server/api/auth): add auth route for server<commit_after>import {Router} from 'express'
import jwt from 'jsonwebtoken'
import chalk from 'chalk'
// import validator from 'validator'
// {isLength, trim, isAlphanumeric, escape}
const router = Router()

// define the home page route
router.post('/', (req, res) => {
  // const {username, password} = req.body
  // const usernameValidated = validator.isLength(0, 36).is
  // const passwordValidated =
  const data = {username: 'cool_username_for_testing'}
  jwt.sign(data, process.env.JWT_SECRET, (err, token) => {
    if (err) {
      throw new Error(
        `Cant create JWT token based on input data: ${JSON.stringify(data)}`,
        err
      )
    }
    console.log(chalk.yellow(`Generated token for user: ${data.username}`))
    res.json({token})
  })
})

export default router
{'fraction_non_alphanumeric': 0.14669223394055608, 'fraction_numerical': 0.0028763183125599234, 'mean_word_length': 3.8110599078341014, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '789549', 'n_tokens_mistral': 339, 'n_tokens_neox': 335, 'n_words': 97}