<commit_before>import { Router, Request, Response, NextFunction } from 'express';

import * as gameCommands from '../game/commands';

class CommandRouter {
    router: Router;

    constructor() {
        this.router = Router();
        this.init();
    }

    init() {
        this.router.use((req: Request, res: Response, next: NextFunction) => {
            const body = req.body;

            if (body.token !== process.env.SLACK_VERIFICATION_TOKEN) {
                res.sendStatus(401);
            }
            next();
        });

        this.router.post('/in', this.joinGame);
    }

    joinGame(req: Request, res: Response) {
        const playerId = req.body.user_id;
        const result = gameCommands.JoinGame(playerId);

        if (result) {
            res.json({ text: 'You are now signed up!' });
        } else {
            res.json({ text: 'You are already signed up!' });
        }
    }
}

const commandRoutes = new CommandRouter();
commandRoutes.init();

export default commandRoutes.router;<commit_msg>make sure auth middleware fails without continuing<commit_after>import { Router, Request, Response, NextFunction } from 'express';

import * as gameCommands from '../game/commands';

class CommandRouter {
    router: Router;

    constructor() {
        this.router = Router();
        this.init();
    }

    init() {
        this.router.use((req: Request, res: Response, next: NextFunction) => {
            const body = req.body;

            if (body.token !== process.env.SLACK_VERIFICATION_TOKEN) {
                return res.sendStatus(401);
            }
            next();
        });

        this.router.post('/in', this.joinGame);
    }

    joinGame(req: Request, res: Response) {
        const playerId = req.body.user_id;
        const result = gameCommands.JoinGame(playerId);

        if (result) {
            res.json({ text: 'You are now signed up!' });
        } else {
            res.json({ text: 'You are already signed up!' });
        }
    }
}

const commandRoutes = new CommandRouter();
commandRoutes.init();

export default commandRoutes.router;
{'fraction_non_alphanumeric': 0.13105413105413105, 'fraction_numerical': 0.002849002849002849, 'mean_word_length': 2.1636636636636637, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1275808', 'n_tokens_mistral': 609, 'n_tokens_neox': 595, 'n_words': 150}