'use strict';

const path = require('path');
module.exports = appInfo => {
    const config = exports = {};

    // use for cookie sign key, should change to your own and keep security
    config.keys = appInfo.name + '_smartcost3850888';

    // 数据库配置
    config.mysql = {
        client: {
            // host
            host: '127.0.0.1',
            // 端口号
            port: '3306',
            // 用户名
            user: 'root',
            // 密码
            password: 'admin',
            // 数据库名
            database: 'index_sys',
        },
        // 是否加载到 app 上，默认开启
        app: true,
        // 是否加载到 agent 上，默认关闭
        agent: false,
    };

    // view
    config.view = {
        mapping: {
            '.ejs': 'ejs',
        },
        root: [
            path.join(appInfo.baseDir, 'app/view'),
        ].join(','),
    };

    // session
    config.session = {
        key: 'ZHC_SESS',
        maxAge: 3600 * 1000,
        httpOnly: true,
        encrypt: true,
    };
    // 表名前缀
    config.tablePrefix = 'is_';

    // add your config here
    config.middleware = ['urlParse'];

    // 上传设置
    config.multipart = {
        whitelist: ['.xls', '.xlsx', '.json'],
        fileSize: '10mb',
    };

    return config;
};
