<commit_before>import * as express from "express";
import * as helpers from "../../../helpers/index";

abstract class IRequestHandler {
    public req: express.Request;
    public res: express.Response;
    public next: Function;

    public constructor(init: Partial<IRequestHandler>) {
        Object.assign(this, init);
    }

    public error(err: number, more?: {[key: string]: any}): void {
        if (!more) {
            more = {};
        }
        more["error"] = err;
        this.res.raw = more;
    }

    public result(result: number, more?: {[key: string]: any}): void {
        if (!more) {
            more = {};
        }
        more["result"] = result;
        this.res.raw = more;
    }

    public redirect(url: string): void {
        this.res.redirect(303, url);
        this.res.end();
        this.res.finished = true;
    }

    public async saveSession(): Promise<void> {
        return helpers.session.save(this.req.session);
    }

    public isLoggedIn(): boolean {
        return this.req.session !== undefined && this.req.session.userid !== undefined;
    }
}

export default IRequestHandler;<commit_msg>Fix some small issues in IRequestHandler<commit_after>import * as express from "express";
import * as helpers from "../../../helpers/index";

abstract class IRequestHandler {
    public req: express.Request;
    public res: express.Response;
    public next: Function;

    public constructor(init: Partial<IRequestHandler>) {
        Object.assign(this, init);
    }

    public error(code: number, more?: {[key: string]: any}): void { this.sendRawResponse("error", code, more); }
    public result(code: number, more?: {[key: string]: any}): void { this.sendRawResponse("result", code, more); }

    public redirect(url: string): void {
        this.res.redirect(303, url);
        this.res.end();
        this.res.finished = true;
    }

    public saveSession(): Promise<void> {
        return helpers.session.save(this.req.session);
    }

    public isLoggedIn(): boolean {
        return this.req.session !== undefined && this.req.session.userid !== undefined;
    }

    private sendRawResponse(name: string, code: number, more?: {[key: string]: any}): void {
        if (!more) more = {};
        more[name] = code;
        this.res.raw = more;
    }
}

export default IRequestHandler;
{'fraction_non_alphanumeric': 0.14665523156089194, 'fraction_numerical': 0.002572898799313894, 'mean_word_length': 2.622670807453416, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3506904', 'n_tokens_mistral': 688, 'n_tokens_neox': 674, 'n_words': 178}