Skip to content

Commit

Permalink
feat(rest-api): add getGroups to rest api
Browse files Browse the repository at this point in the history
  • Loading branch information
stropitek committed Sep 1, 2016
1 parent 7093cfc commit 0dff073
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/server/middleware/couch.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,15 @@ exports.getGroup = function*() {
}
};

exports.getGroups = function*() {
try {
var right = this.params.right || 'read';
this.body = yield this.state.couch.getGroupsByRight(this.state.userEmail, right);
} catch (e) {
onGetError(this, e);
}
};

/* todo implement it
exports.createOrUpdateGroup = function *() {
try {
Expand Down
1 change: 1 addition & 0 deletions src/server/routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ exports.init = function () {

// Groups
router.get('/:dbname/group/:name', couch.getGroup);
router.get('/:dbname/groups', couch.getGroups);
//router.put('/:dbname/group/:name', parseJson1mb, couch.createOrUpdateGroup);
router.delete('/:dbname/group/:name', couch.deleteGroup);

Expand Down
6 changes: 6 additions & 0 deletions test/rest-api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,10 @@ describe('basic rest-api as a@a.com', function () {
response.body.should.have.properties(['name', 'users', 'rights']);
});
});

it('get list of groups', function () {
return request.get('/db/test/groups').expect(200).then(function (response) {
response.body.should.deepEqual(['groupA']);
});
});
});

0 comments on commit 0dff073

Please sign in to comment.