{"size": 1980, "ext": "js", "max_stars_repo_path": "egg-typeorm.js", "max_stars_repo_name": "MMF-FE/icp-log", "max_stars_repo_stars_event_min_datetime": "2020-10-23T06:51:12.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-23T06:51:12.000Z", "max_issues_repo_path": "egg-typeorm.js", "max_issues_repo_name": "MMF-FE/icp-log", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "egg-typeorm.js", "max_forks_repo_name": "MMF-FE/icp-log", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 82.5, "max_line_length": 1118, "alphanum_fraction": 0.8454545455}
"use strict";
/**
 * 数据库连接
 * @author vfasky<vfasky@gmail.com>
 **/
Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const typeorm_1 = require("typeorm");
exports.default = async (app) => {
    const config = app.config.typeorm;
    // 连接 数据库
    assert(config.type && config.database, `[typeorm] 'host: ${config.type}', 'database: ${config.database}' are required on config`);
    const connection = await typeorm_1.createConnection(config);
    // @ts-ignore
    app.typeorm = connection;
    let count = 1;
    app.beforeStart(async function startQuery() {
        const rows = await connection.manager.query('select 1 as column1;');
        const index = count++;
        app.coreLogger.info(`[typeorm] instance[${index}] status OK, rds currentTime: ${rows[0].currentTime}`);
    });
    return connection;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZWdnLXR5cGVvcm0uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJlZ2ctdHlwZW9ybS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7OztJQUdJOztBQUlKLGlDQUFnQztBQUNoQyxxQ0FBNkQ7QUFFN0Qsa0JBQWUsS0FBSyxFQUFFLEdBQWdCLEVBQUUsRUFBRTtJQUN0QyxNQUFNLE1BQU0sR0FBRyxHQUFH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