web/modules/db.js

18 lines
301 B
JavaScript
Raw Normal View History

2021-11-15 10:58:59 +01:00
var mysql = require('mysql2');
2021-11-15 11:35:31 +01:00
2021-11-15 11:56:20 +01:00
let config;
2021-11-15 11:35:31 +01:00
try {
2021-11-15 11:56:20 +01:00
config = require('../config');
2021-11-15 11:35:31 +01:00
} catch (e) {
console.log('No config file found');
2021-11-15 11:56:20 +01:00
process.exit(0);
2021-11-15 11:35:31 +01:00
}
2021-11-15 10:58:59 +01:00
2021-11-15 11:05:44 +01:00
function connect() {
2021-11-15 10:58:59 +01:00
const connection = mysql.createConnection(config.db);
return connection;
}
module.exports = {
connect
}