vn-rfid/db/connect.js

14 lines
418 B
JavaScript
Raw Normal View History

2023-01-24 09:11:58 +00:00
import mysql from 'mysql2/promise';
import yml from 'require-yml';
import path from 'path';
import fs from 'fs-extra';
const {pathname: root} = new URL('../', import.meta.url);
let conf = yml(path.join(root, 'config.yml'));
const localConfFile = path.join(root, 'config.local.yml');
if (fs.existsSync(localConfFile))
conf = Object.assign({}, conf, yml(localConfFile));
export default mysql.createPool(conf.db);