Skip to content
This repository was archived by the owner on May 10, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
"id":"uid"
},
"hypertopic":{
"uid": "id",
"displayName": "name",
"jpegPhoto": "thumbnail"
"uid": ["id"],
"displayName": ["name"],
"jpegPhoto": ["thumbnail", "resource"]
},
"reserved":{
"attributes":{
"dn":0,
"uid":0,
"dn":0,
"uid":0,
"controls":0
},
"values":{
Expand Down
27 changes: 23 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ var payload = {
for (var attribute in entry) {
if (!(attribute in config.reserved.attributes || entry[attribute] in config.reserved.values)) {
var value = {};
value[config.hypertopic[attribute]||attribute] = entry[attribute];
this.rows.push({
if(config.hypertopic[attribute]){
for(var indexAttribute in config.hypertopic[attribute]){
value[config.hypertopic[attribute][indexAttribute]] = entry[attribute];
}
}else{
value[attribute] = entry[attribute];
}
this.rows.push({
key: key,
value: value
});
Expand All @@ -37,7 +43,7 @@ function sendItems(request, response) {
filter = '(&' + filter + '('+ config.ldap.id + '=' + request.params.item + '))';
}
var options = {
scope: 'sub',
scope: 'sub',
filter: filter,
attributes: config.ldap.attributes
};
Expand All @@ -55,8 +61,21 @@ function sendItems(request, response) {
});
}

function sendEmpty(request, response){
response.json({rows: []});
}

function sendUser(request, response){
response.json({rows: [{
key:'annuaire',
value:{"corpus":{"id":"student", "name":"Étudiants"}}
}]});
}

app.use(cors)
.get(['/corpus/:corpus', '/item/:corpus/:item'], sendItems);
.get(['/corpus/:corpus', '/item/:corpus/:item'], sendItems)
.get('/viewpoint/:viewpoint', sendEmpty)
.get('/user/annuaire', sendUser);

app.listen(config.port);
console.log('Server running on port ' + config.port);