Commit 8ead1f9e authored by Johannes Bill's avatar Johannes Bill

fixed error propagaytion

parent 0ae32c35
......@@ -3,9 +3,8 @@
"restApiPort": 3001,
"mysqlConfig": {
"host": "127.0.0.1",
"port": 3306,
"database": "gemeindeschluessel",
"username": "root",
"password": "bla"
"user": "root",
"password": "ntgf42raUpaD",
"database": "holidays"
}
}
\ No newline at end of file
var mysql = require('mysql');
var config = require('../config.json');
var blndMapping = {
"Baden-Württemberg": "BW",
"Niedersachsen": "NI",
"Bayern": "BY",
"Nordrhein-Westfalen": "NW",
"Berlin": "BE",
"Rheinland-Pfalz": "RP",
"Brandenburg": "BB",
"Saarland": "SL",
"Bremen": "HB",
"Sachsen": "SN",
"Hamburg": "HH",
"Sachsen-Anhalt": "ST",
"Hessen": "HE",
"Schleswig-Holstein": "SH",
"Mecklenburg-Vorpommern": "MV",
"Thüringen": "TH"
};
console.log(config["mysqlConfig"]);
var connection = mysql.createConnection(config["mysqlConfig"]);
module.exports.getBundesland = function(plz, cb) {
connection.query("SELECT bundesland FROM postleitzahlen WHERE plz = " + plz, function (err, result) {
if (err) return cb(err);
var blnd;
try {
blnd = result[0]['bundesland'];
blnd = blndMapping[blnd];
}
catch(err) {
return cb(err);
}
if (blnd === undefined)
return cb(new Error("no bundesland found for plz " + plz));
cb(null, blnd);
});
};
module.exports.getKatholisch = function(plz, cb) {
connection.query("SELECT feiertag FROM relHoliday WHERE plz = " + plz, function (err, result) {
if (err) return cb(err);
var feiertag;
try {
feiertag = result[0]["feiertag"];
}
catch (error) {
return cb(err);
}
if (feiertag === undefined)
return cb(new Error("no entry found in religion table for plz " + plz));
cb(null, !!feiertag);
});
};
/*getBundesland(4600, function (err, result) {
console.log(err);
console.log(result);
});*/
/*getKatholisch(93047, function (err, result) {
console.log(err);
console.log(result);
});*/
var holidayMapping = require('./holidayMapping.json');
var easterSunday = require('./easterSunday');
var restRequest = require('./blndRelRequest');
var restRequest = require('./blndRelDbRequest');
var SimplQueue = require('./simplQueue');
var easterSundays = {};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment