Use configured database file.

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

View file

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

View file

@ -1,46 +1,55 @@
'use strict'; 'use strict';
angular.module('ffffng').factory('config', function (fs, deepExtend) { var fs = require('fs');
var defaultConfig = { var deepExtend = require('deep-extend');
server: {
baseUrl: 'http://localhost:8080',
port: 8080,
peersPath: '/tmp/peers',
email: { var defaultConfig = {
from: 'no-reply@musterstadt.freifunk.net' server: {
} baseUrl: 'http://localhost:8080',
port: 8080,
databaseFile: '/tmp/ffffng.sqlite',
peersPath: '/tmp/peers',
email: {
from: 'no-reply@musterstadt.freifunk.net'
}
},
client: {
community: {
name: 'Freifunk Musterstadt',
domain: 'musterstadt.freifunk.net',
contactEmail: 'kontakt@musterstadt.freifunk.net'
}, },
client: { map: {
community: { graphUrl: 'http://graph.musterstadt.freifunk.net/graph.html',
name: 'Freifunk Musterstadt', mapUrl: 'http://graph.musterstadt.freifunk.net/geomap.html'
domain: 'musterstadt.freifunk.net', },
contactEmail: 'kontakt@musterstadt.freifunk.net' monitoring: {
}, enabled: true
map: { },
graphUrl: 'http://graph.musterstadt.freifunk.net/graph.html', coordsSelector: {
mapUrl: 'http://graph.musterstadt.freifunk.net/geomap.html' showInfo: false,
}, showBorderForDebugging: false,
monitoring: { localCommunityPolygon: [],
enabled: true lat: 53.565278,
}, lng: 10.001389,
coordsSelector: { defaultZoom: 10
showInfo: false,
showBorderForDebugging: false,
localCommunityPolygon: [],
lat: 53.565278,
lng: 10.001389,
defaultZoom: 10
}
} }
};
var configJSONFile = __dirname + '/../config.json';
var configJSON = {};
if (fs.existsSync(configJSONFile)) {
configJSON = JSON.parse(fs.readFileSync(configJSONFile, 'utf8'));
} }
};
return deepExtend({}, defaultConfig, configJSON); var configJSONFile = __dirname + '/../config.json';
var configJSON = {};
if (fs.existsSync(configJSONFile)) {
configJSON = JSON.parse(fs.readFileSync(configJSONFile, 'utf8'));
}
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 glob = require('glob');
var path = require('path'); var path = require('path');
var config = require('../config');
function applyPatch(db, file, callback) { function applyPatch(db, file, callback) {
fs.readFile(file, function (err, contents) { fs.readFile(file, function (err, contents) {
if (err) { if (err) {
@ -62,7 +64,7 @@ function applyMigrations(db, callback) {
module.exports = { module.exports = {
init: function (callback) { init: function (callback) {
var SQLite3 = require('sqlite3'); var SQLite3 = require('sqlite3');
var db = new SQLite3.Database('/tmp/test.sqlite'); var db = new SQLite3.Database(config.server.databaseFile);
applyMigrations(db, function (err) { applyMigrations(db, function (err) {
if (err) { if (err) {