Skip to content
Permalink
Browse files

implemented semantic unit API

  • Loading branch information
vecna committed Sep 10, 2019
1 parent 2683b2b commit 05502bb7817860495c08f5876c184d55da8c9785
Showing with 26 additions and 1 deletion.
  1. +5 −0 lib/contentAPI.js
  2. +21 −1 routes/semantics.js
@@ -153,5 +153,10 @@ module.exports = [
desc: "Keywords",
route: '/api/v2/keywords/:lang',
func: require('../routes/semantics').keywords,
},
{
desc: "Unit",
route: '/api/v2/unit/:semanticId',
func: require('../routes/semantics').unit,
}
];
@@ -292,6 +292,25 @@ function keywords(req) {
});
};

function unit(req) {
const semanticId = req.params.semanticId;
debug("semantic unit query: %s", semanticId);
return Promise.all([
mongo.read(nconf.get('schema').semantics, { semanticId: semanticId }),
mongo.read(nconf.get('schema').summary, { semanticId: semanticId })
])
.then(function(e) {
debug("Found %d semantics and %d posts!",
_.size(e[0]), _.size(e[1]) );
return {
json: {
labels: _.map(e[0], function(semantic) { return _.omit(semantic, ['_id']); }),
posts: _.map(e[1], function(post) { return _.omit(post, ['_id']); })
}
};
})
}

module.exports = {
labels,
semantics,
@@ -300,5 +319,6 @@ module.exports = {
noogle,
langinfo,
languages,
keywords
keywords,
unit
};

0 comments on commit 05502bb

Please sign in to comment.
You can’t perform that action at this time.