aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/nodejs/start.js52
1 files changed, 27 insertions, 25 deletions
diff --git a/src/nodejs/start.js b/src/nodejs/start.js
index b92c757..52c0748 100644
--- a/src/nodejs/start.js
+++ b/src/nodejs/start.js
@@ -6,27 +6,29 @@ var http = require('http'),
querystring = require('querystring');
// config
-var connectionString = "pg://yves:test@localhost/xapi"
-
-
-function getDataBaseResult(tag,bbox,res){
-pg.connect(connectionString,function(err,client){
- var the_result;
- if(err){
- console.log(err);
- } else {
- client.query(createQuery(tag,bbox),function(err,result){
- if (err) {
- console.log(err);
- } else {
- console.log(result);
- res.write(result.rows);
- res.end("/n");
- }
-
- });
- }
-});
+var connectionString = "pg://user:pass@localhost/xapi"
+
+
+function getDataBaseResult(tag,bbox,res) {
+ pg.connect(connectionString,function(err,client) {
+ var the_result;
+
+ if (err) {
+ console.log(err);
+ }
+ else {
+ client.query(createQuery(tag,bbox),function(err,result) {
+ if (err) {
+ console.log(err);
+ }
+ else {
+ console.log(result);
+ res.write(result.rows);
+ res.end("\n");
+ }
+ });
+ }
+ });
}
@@ -67,13 +69,13 @@ http.createServer(function (req, res) {
}
base_url_re.exec(req.url);
var type = RegExp.$1, url_rest = querystring.unescape(RegExp.$2);
-
+
var filters = [];
while (v = filter_re.exec(url_rest)) {
filters.push(v[1]);
}
console.log(filters);
-
+
var tag;
var bbox;
@@ -90,10 +92,10 @@ http.createServer(function (req, res) {
console.log(tag);
console.log(bbox);
- getDataBaseResult(tag,bbox,res);
+ getDataBaseResult(tag,bbox,res);
res.writeHead(200, {'Content-Type': 'text/plain; charset=utf8', });
-
+
res.write('URL was: ' + req.url + '\n');
res.write('type: ' + type + '\n');
res.write('filters:\n');