Skip to content

Commit 823fa8e

Browse files
authored
Merge pull request kunalkapadia#372 from KunalKapadia/develop
limit cast fix and remove port from mongoUri
2 parents 9b85d64 + eebfabc commit 823fa8e

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Promise = require('bluebird'); // eslint-disable-line no-global-assign
1414
mongoose.Promise = Promise;
1515

1616
// connect to mongo db
17-
const mongoUri = `${config.mongo.host}:${config.mongo.port}`;
17+
const mongoUri = config.mongo.host;
1818
mongoose.connect(mongoUri, { server: { socketOptions: { keepAlive: 1 } } });
1919
mongoose.connection.on('error', () => {
2020
throw new Error(`unable to connect to database: ${config.db}`);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"cross-env": "3.1.3",
7474
"cz-conventional-changelog": "1.2.0",
7575
"del": "^2.2.0",
76-
"eslint": "3.16.0",
76+
"eslint": "3.16.1",
7777
"eslint-config-airbnb-base": "7.1.0",
7878
"eslint-plugin-import": "1.16.0",
7979
"eslint-watch": "2.1.14",

server/models/user.model.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ UserSchema.statics = {
6565
list({ skip = 0, limit = 50 } = {}) {
6666
return this.find()
6767
.sort({ createdAt: -1 })
68-
.skip(skip)
69-
.limit(limit)
68+
.skip(+skip)
69+
.limit(+limit)
7070
.exec();
7171
}
7272
};

server/tests/user.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,18 @@ describe('## User APIs', () => {
9191
})
9292
.catch(done);
9393
});
94+
95+
it('should get all users (with limit and skip)', (done) => {
96+
request(app)
97+
.get('/api/users')
98+
.query({ limit: 10, skip: 1 })
99+
.expect(httpStatus.OK)
100+
.then((res) => {
101+
expect(res.body).to.be.an('array');
102+
done();
103+
})
104+
.catch(done);
105+
});
94106
});
95107

96108
describe('# DELETE /api/users/', () => {

0 commit comments

Comments
 (0)