Use configured database file.

This commit is contained in:
baldo 2016-05-20 22:38:13 +02:00
commit 8102181a7e
3 changed files with 53 additions and 40 deletions

View file

@ -2,6 +2,8 @@
"server": {
"baseUrl": "http://localhost:8080",
"port": 8080,
"databaseFile": "/tmp/ffffng.sqlite",
"peersPath": "/tmp/peers",
"email": {

View file

@ -1,10 +1,14 @@
'use strict';
angular.module('ffffng').factory('config', function (fs, deepExtend) {
var fs = require('fs');
var deepExtend = require('deep-extend');
var defaultConfig = {
server: {
baseUrl: 'http://localhost:8080',
port: 8080,
databaseFile: '/tmp/ffffng.sqlite',
peersPath: '/tmp/peers',
email: {
@ -42,5 +46,10 @@ angular.module('ffffng').factory('config', function (fs, deepExtend) {
configJSON = JSON.parse(fs.readFileSync(configJSONFile, 'utf8'));
}
return deepExtend({}, defaultConfig, configJSON);
var config = deepExtend({}, defaultConfig, configJSON);
module.exports = config;
angular.module('ffffng').factory('config', function () {
return config;
});

View file

@ -5,6 +5,8 @@ var fs = require('fs');
var glob = require('glob');
var path = require('path');
var config = require('../config');
function applyPatch(db, file, callback) {
fs.readFile(file, function (err, contents) {
if (err) {
@ -62,7 +64,7 @@ function applyMigrations(db, callback) {
module.exports = {
init: function (callback) {
var SQLite3 = require('sqlite3');
var db = new SQLite3.Database('/tmp/test.sqlite');
var db = new SQLite3.Database(config.server.databaseFile);
applyMigrations(db, function (err) {
if (err) {