bedrock-account-http
Advanced tools
Comparing version
# bedrock-account-http ChangeLog | ||
## 2.0.0 - 2021-01-12 | ||
### Changed | ||
- **BREAKING**: Remove limit option | ||
- **BREAKING**: Update bedrock-account@5. | ||
## 1.7.0 - 2020-07-07 | ||
@@ -4,0 +10,0 @@ |
@@ -104,3 +104,2 @@ /*! | ||
* @param {Boolean} req.query.exists - used by Registration | ||
* @param {Number} req.query.limit | ||
* @param {String} req.query.cursor - an account id | ||
@@ -125,3 +124,3 @@ * @description Gets account records (or checks for their existence). | ||
} | ||
const {email, after = null, limit = 10} = req.query; | ||
const {email, after = null} = req.query; | ||
const {actor} = req.user || {}; | ||
@@ -139,3 +138,3 @@ const query = {'account.email': email}; | ||
}; | ||
const options = {limit, sort: {'account.id': -1}}; | ||
const options = {sort: {'account.id': -1}}; | ||
const records = await brAccount.getAll({actor, query, fields, options}); | ||
@@ -142,0 +141,0 @@ res.json(records); |
{ | ||
"name": "bedrock-account-http", | ||
"version": "1.7.0", | ||
"version": "2.0.0", | ||
"description": "HTTP API for Bedrock User Accounts", | ||
@@ -33,3 +33,3 @@ "license": "SEE LICENSE IN LICENSE.md", | ||
"bedrock": "1.12.1 - 3.x", | ||
"bedrock-account": "2.x - 4.x", | ||
"bedrock-account": "^5.0.0", | ||
"bedrock-express": "2.0.8 - 3.x", | ||
@@ -36,0 +36,0 @@ "bedrock-passport": "5.x - 6.x", |
@@ -89,10 +89,11 @@ /*! | ||
it('should return 201 for accounts with the same email', async function() { | ||
it('should return 409 for accounts with the same email', async function() { | ||
const email = {email: 'multiple@digitalbazaar.com'}; | ||
const result1 = await api.post('/', email); | ||
const result2 = await api.post('/', email); | ||
const result3 = await api.post('/', email); | ||
result1.status.should.equal(201); | ||
result2.status.should.equal(201); | ||
result3.status.should.equal(201); | ||
result2.data.type.should.equal('DuplicateError'); | ||
result2.data.message.should.equal('Duplicate account.'); | ||
result2.data.details.httpStatusCode.should.equal(409); | ||
}); | ||
@@ -280,3 +281,3 @@ | ||
it('should return 3 accounts', async function() { | ||
it('should return only 1 account', async function() { | ||
const email = 'multi@example.com'; | ||
@@ -287,32 +288,12 @@ stubPassportStub(Emails.admin); | ||
const {data} = result; | ||
data.length.should.equal(3); | ||
data.forEach(entry => { | ||
entry.should.be.an('object'); | ||
entry.should.have.property('account'); | ||
entry.should.have.property('meta'); | ||
const {account} = entry; | ||
account.should.have.property('id'); | ||
account.should.have.property('email'); | ||
account.email.should.equal(email); | ||
}); | ||
data.length.should.equal(1); | ||
data[0].should.be.an('object'); | ||
data[0].should.have.property('account'); | ||
data[0].should.have.property('meta'); | ||
const {account} = data[0]; | ||
account.should.have.property('id'); | ||
account.should.have.property('email'); | ||
account.email.should.equal(email); | ||
}); | ||
it('should return 2 accounts', async function() { | ||
const email = 'multi@example.com'; | ||
stubPassportStub(Emails.admin); | ||
const result = await api.get('/', {email, limit: 2}); | ||
result.data.should.be.an('array'); | ||
const {data} = result; | ||
data.length.should.equal(2); | ||
data.forEach(entry => { | ||
entry.should.be.an('object'); | ||
entry.should.have.property('account'); | ||
entry.should.have.property('meta'); | ||
const {account} = entry; | ||
account.should.have.property('id'); | ||
account.should.have.property('email'); | ||
account.email.should.equal(email); | ||
}); | ||
}); | ||
it('should return 400 invalid', async function() { | ||
@@ -342,16 +323,3 @@ const email = null; | ||
}); | ||
it('should paginate', async function() { | ||
const email = 'multi@example.com'; | ||
stubPassportStub(Emails.admin); | ||
const result = await api.get('/', {email}); | ||
result.data.should.be.an('array'); | ||
const {data} = result; | ||
data.length.should.equal(3); | ||
const mid = data[data.length - 2]; | ||
const {account: {id}} = mid; | ||
const nextResults = await api.get('/', {email, after: id}); | ||
nextResults.data.should.be.an('array'); | ||
nextResults.data.length.should.equal(1); | ||
}); | ||
}); | ||
}); |
@@ -28,5 +28,5 @@ { | ||
"dependencies": { | ||
"apisauce": "^1.1.1", | ||
"apisauce": "^2.0.0", | ||
"bedrock": "^3.1.1", | ||
"bedrock-account": "^4.0.0", | ||
"bedrock-account": "^5.0.0", | ||
"bedrock-account-http": "file:..", | ||
@@ -33,0 +33,0 @@ "bedrock-express": "^3.2.0", |
36272
-2.96%745
-4.24%