Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxHansson committed Feb 14, 2014
0 parents commit fb2bc01
Show file tree
Hide file tree
Showing 500 changed files with 68,862 additions and 0 deletions.
Empty file added README.md
Empty file.
56 changes: 56 additions & 0 deletions api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
var express = require('express');
var app = express();

var databaseUrl = 'root:[email protected]:41022/POIDB'; // "username:[email protected]/mydb"
//var databaseUrl = 'localhost/POIDB'; // "username:[email protected]/mydb"
var collections = ['pois', 'poiTypes'];
var db = require('mongojs').connect(databaseUrl, collections);

//Get the different poi-types
app.get('/types', function(req, res){
'use strict';
db.poiTypes.find({}, {Name: 1}, function(err, data){
res.send(data);
});
});

//Get pois by type(category)
app.get('/pois/:type', function(req, res){
'use strict';

var type = req.params.type;
db.pois.find({POIType: type}, function(err, data){
res.send(200, data);
});
});

//Get all data
app.get('/pois', function(req, res){
'use strict';
var query = req.query;
console.log(query);
db.pois.find(query, function(err, data){
res.send(200, data);
});

});

//Search all pois
app.get('/search', function(req, res){
'use strict';
var query = req.query;
db.pois.find({'Name': new RegExp(query.query, 'i')}, function(err, data){
res.send(200, data);
console.log(err);
console.log(data);
});
});

//Not found 404 error stuff
app.get('*', function(req, res){
'use strict';

res.sendfile('error/404.html');
});

app.listen(8087);
40 changes: 40 additions & 0 deletions error/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<html>

<head>
<title>Open-DAI Error: 404</title>
<style>
body {
font-family: Arial;
font-size: 9pt;
}
.bigger {
font-size:90pt;
margin:0;

}
div {
width:600px;
margin:0 auto;
text-align: center;
}
span {
font-weight: bold;
}
p {
font-style: italic;
}
</style>
</head>

<body>
<div>
<img src="https://github-camo.global.ssl.fastly.net/900e822b1e968b32240a7e3e4abbf367363b77b5/687474703a2f2f7777772e6e6574706f72742e73652f77702d636f6e74656e742f75706c6f6164732f323031322f30322f6f70656e2d6461692e6a7067" />
<h1 class="bigger">404</h1>
<span>Something is wrong and Open-DAI cannot serve you this data. Please choose the right path.</span>
<p>The 404 or Not Found error message is a HTTP standard response code indicating that the client was able to communicate with the server, but the server could not find what was requested.
The web site hosting server will typically generate a "404 Not Found" web page when a user attempts to follow a broken or dead link; hence the 404 error is one of the most recognizable errors users can find on the web.[1]
A 404 error should not be confused with "server not found" or similar errors, in which a connection to the destination server could not be made at all. A 404 error indicates that the requested resource may be available again in the future; however, the fact does not guarantee the same content.</p>
</div>
</body>

</html>
1 change: 1 addition & 0 deletions node_modules/.bin/express

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions node_modules/express/.npmignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions node_modules/express/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fb2bc01

Please sign in to comment.