Skip to content
Snippets Groups Projects
Commit dfbe4f47 authored by René Gulager Larsen's avatar René Gulager Larsen
Browse files

added serviceREsponce function again.

parent bfdf2782
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -122,7 +122,15 @@ app.get('/delete/:id', function(req,res){
});
app.get('/:id/:lang', function(req,res ){
var id = parseInt(req.params.id);
var lang = req.params.lang;
single(id,lang,function(result){
});
});
app.get('/rebuild/', function (req,res) {
var courseList;
......@@ -155,6 +163,34 @@ app.get('/rebuild/', function (req,res) {
* Get a single course from eddie, based on an id + language
*
* */
function single(id,lang,callback) {
MongoClient.connect(mongoUrl, function (err, db) {
var collection = db.collection('courses');
if (err) {
console.log('Unable to connect to the mongoDB server. Error:', err + "course id".id);
} else {
collection.find(
{
'courseId': id,
'presentationLanguage': lang
}).toArray(function (err, result) {
if (err) {
console.log(err);
} else if (result.length) {
console.log('Found:', result);
} else {
console.log('No document(s) found with defined "find" criteria!');
}
//Close connection
db.close();
});
}
callback();
});
}
function getSingleFromEddie(task,callback) {
url = eddieUrl + 'getCourseList';
......@@ -207,7 +243,6 @@ function getSingleFromEddie(task,callback) {
}//fi
callback();
});//end request
......@@ -233,6 +268,10 @@ function getCourselistFromEddie (callback) {
});//end request
}
function serviceResponse(req, res) {
res.json({result:200});
res.end();
};
var server = app.listen(8081, function () {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment