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": {
|
"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": {
|
||||||
|
|
|
@ -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,
|
||||||
client: {
|
|
||||||
community: {
|
databaseFile: '/tmp/ffffng.sqlite',
|
||||||
name: 'Freifunk Musterstadt',
|
peersPath: '/tmp/peers',
|
||||||
domain: 'musterstadt.freifunk.net',
|
|
||||||
contactEmail: 'kontakt@musterstadt.freifunk.net'
|
email: {
|
||||||
},
|
from: 'no-reply@musterstadt.freifunk.net'
|
||||||
map: {
|
}
|
||||||
graphUrl: 'http://graph.musterstadt.freifunk.net/graph.html',
|
},
|
||||||
mapUrl: 'http://graph.musterstadt.freifunk.net/geomap.html'
|
client: {
|
||||||
},
|
community: {
|
||||||
monitoring: {
|
name: 'Freifunk Musterstadt',
|
||||||
enabled: true
|
domain: 'musterstadt.freifunk.net',
|
||||||
},
|
contactEmail: 'kontakt@musterstadt.freifunk.net'
|
||||||
coordsSelector: {
|
},
|
||||||
showInfo: false,
|
map: {
|
||||||
showBorderForDebugging: false,
|
graphUrl: 'http://graph.musterstadt.freifunk.net/graph.html',
|
||||||
localCommunityPolygon: [],
|
mapUrl: 'http://graph.musterstadt.freifunk.net/geomap.html'
|
||||||
lat: 53.565278,
|
},
|
||||||
lng: 10.001389,
|
monitoring: {
|
||||||
defaultZoom: 10
|
enabled: true
|
||||||
}
|
},
|
||||||
|
coordsSelector: {
|
||||||
|
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;
|
||||||
});
|
});
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue