API Initial commit
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
const mysql = require("mysql");
|
||||
const fs = require("fs");
|
||||
|
||||
const state = {
|
||||
pool: null
|
||||
};
|
||||
|
||||
exports.connect = function(done){
|
||||
state.pool = mysql.createPool({
|
||||
host: 'localhost',
|
||||
user: 'root',
|
||||
password: 'root',
|
||||
port: 3306,
|
||||
database: "territory-walker",
|
||||
//multipleStatements: true
|
||||
});
|
||||
done();
|
||||
};
|
||||
|
||||
exports.get = function(){
|
||||
return state.pool;
|
||||
};
|
||||
|
||||
exports.addTables = function(done) {
|
||||
fs.readFile('res/database_setup.sql', 'utf-8', function(err, result){
|
||||
if(err) return done(err);
|
||||
state.pool.query(result, function(err, result) {
|
||||
if (err) return done(err);
|
||||
return done(false, result);
|
||||
});
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user