Use configured database file.
This commit is contained in:
parent
03271573be
commit
8102181a7e
3 changed files with 53 additions and 40 deletions
|
@ -2,6 +2,8 @@
|
|||
"server": {
|
||||
"baseUrl": "http://localhost:8080",
|
||||
"port": 8080,
|
||||
|
||||
"databaseFile": "/tmp/ffffng.sqlite",
|
||||
"peersPath": "/tmp/peers",
|
||||
|
||||
"email": {
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('ffffng').factory('config', function (fs, deepExtend) {
|
||||
var defaultConfig = {
|
||||
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: {
|
||||
|
@ -33,14 +37,19 @@ angular.module('ffffng').factory('config', function (fs, deepExtend) {
|
|||
defaultZoom: 10
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var configJSONFile = __dirname + '/../config.json';
|
||||
var configJSON = {};
|
||||
var configJSONFile = __dirname + '/../config.json';
|
||||
var configJSON = {};
|
||||
|
||||
if (fs.existsSync(configJSONFile)) {
|
||||
if (fs.existsSync(configJSONFile)) {
|
||||
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;
|
||||
});
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue