<commit_before>import { normalize, join } from 'path';

export interface FlaskOptions {
    staticFolder?: string;
    templateFolder?: string;
    statucOptins?: StaticServerOptions
}

export interface FlaskRuntimeOptions {
    debug?: boolean;
    port?: number;
    hostname?: string;
}

export interface StaticServerOptions {
    cache?: number | boolean
    gzip?: boolean | RegExp
}

export class Configs {
    flaskOptions: {
        rootPath: string
        staticPath: string
        templatesPath: string
    };
    staticServerOptions: StaticServerOptions;
    formOptions: {
        autoSave: boolean
        uploadPath: string
    };
    runTimeOptions: {
        debug: boolean
        port: number
        hostname: string
    };

    constructor() {
        this.flaskOptions = {
            rootPath: '',
            staticPath: '',
            templatesPath: ''
        };
        this.staticServerOptions = {
            cache: 3600,
            gzip: true
        };
        this.formOptions = {
            autoSave: false,
            uploadPath: undefined
        };
        this.runTimeOptions = {
            debug: false,
            port: 5050,
            hostname: 'localhost'
        }
    }

    setConfigs(rootPath, options: FlaskOptions) {
        options = Object.assign({
            staticFolder: 'static',
            templateFolder: 'template'
        }, options);

        let flaskOptions = this.flaskOptions;
        flaskOptions.rootPath = rootPath;
        flaskOptions.staticPath = join(rootPath, normalize(options.staticFolder));
        flaskOptions.templatesPath = join(rootPath, normalize(options.templateFolder));
    };

    setRunTime(options) {
        let defaultOptions = {
            port: 5050,
            hostname: '127.0.0.1',
            debug: false
        };

        this.runTimeOptions = Object.assign(defaultOptions, options);
    };
};<commit_msg>doc(config): add doc<commit_after>import { normalize, join } from 'path';

/**
 * Flask app options
 * 
 * @export
 * @interface FlaskOptions
 */
export interface FlaskOptions {
    /**
     * static file folder
     * 
     * @type {string}
     * @memberOf FlaskOptions
     */
    staticFolder?: string
    /**
     * template file folder
     * 
     * @type {string}
     * @memberOf FlaskOptions
     */
    templateFolder?: string
    /**
     * Static server options
     * 
     * @type {StaticServerOptions}
     * @memberOf FlaskOptions
     */
    staticOptions?: StaticServerOptions
}

/**
 * 
 * 
 * @export
 * @interface StaticServerOptions
 */
export interface StaticServerOptions {
    /**
     * whether open cahce
     * if debug is true, this cahce is useless
     * 
     * @type {(number | boolean)}
     * @memberOf StaticServerOptions
     */
    cache?: number | boolean
    /**
     * whether open gizp
     * 
     * @type {(boolean | RegExp)}
     * @memberOf StaticServerOptions
     */
    gzip?: boolean | RegExp
}

/**
 * run time options 
 * 
 * @export
 * @interface RunTimeOptions
 */
export interface RunTimeOptions {
    /**
      * whether open debug mode
      * 
      * @type {boolean}
      * @default false
      * @memberOf FlaskRuntimeOptions
      */
    debug?: boolean
    /**
     * server port 
     * 
     * @type {number}
     * @default 5050
     * @memberOf FlaskRuntimeOptions
     */
    port?: number
    /**
     * server hostname
     * 
     * @type {string}
     * @default localhost
     * @memberOf FlaskRuntimeOptions
     */
    hostname?: string
}

export class Configs {
    flaskOptions: {
        rootPath: string
        staticPath: string
        templatesPath: string
    };
    staticServerOptions: {
        rootPath: string
        gzip: boolean | RegExp
        cache: number | boolean
    };
    runTimeOptions: RunTimeOptions;

    constructor() {
        this.flaskOptions = {
            rootPath: '',
            staticPath: '',
            templatesPath: ''
        };
        this.staticServerOptions = {
            cache: 3600,
            gzip: true,
            rootPath: ''
        };
        this.runTimeOptions = {
            debug: false,
            port: 5050,
            hostname: 'localhost'
        }
    }

    setConfigs(rootPath, options: FlaskOptions) {
        let {staticFolder, templateFolder} = Object.assign({
            staticFolder: options.staticFolder,
            templateFolder: options.templateFolder
        }, {
            staticFolder: 'static',
            templateFolder: 'templates'
        });

        let flaskOptions = this.flaskOptions;
        flaskOptions.rootPath = rootPath;
        flaskOptions.staticPath = join(rootPath, normalize(staticFolder));
        flaskOptions.templatesPath = join(rootPath, normalize(templateFolder));

        this.staticServerOptions.rootPath = flaskOptions.staticPath;

        if (options.staticOptions) {
            this.staticServerOptions = Object.assign(this.staticServerOptions, options.staticOptions)
        }
    };

    setRunTime(options) {
        this.runTimeOptions = Object.assign(this.runTimeOptions, options);
    };
};
{'fraction_non_alphanumeric': 0.10127077223851418, 'fraction_numerical': 0.005865102639296188, 'mean_word_length': 1.95040369088812, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '176488', 'n_tokens_mistral': 1445, 'n_tokens_neox': 1378, 'n_words': 307}