Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 548f0b2

Browse files
committed
Change readme to describe the project
Add pagination to the endpoint
1 parent 22579c3 commit 548f0b2

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
1-
# codingChallenge
1+
# README #
2+
3+
This README would normally document whatever steps are necessary to get your application up and running.
4+
5+
### What is this repository for? ###
6+
7+
* This is the backend of an app for a contest of Bob.io
8+
* 0.0.1
9+
10+
### How do I get set up? ###
11+
12+
* How to run tests (TODO)
13+
14+
* To run the backend, simply use node path/of/your/folder/backend/server.js

components/customer/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ exports.remove = remove;
1111
/**
1212
* Method that return a list of customers
1313
*/
14-
function list() {
15-
return Store.list().then(customers => {
14+
function list(query) {
15+
return Store.list(query.offset, query.limit).then(customers => {
1616
return { data: customers };
1717
});
1818
}

components/customer/network.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const Response = require('../../network/response');
33
const Controller = require('./');
44

55
router.get('/', (req, res, next) => {
6-
Controller.list().then(response => {
6+
Controller.list(req.query).then(response => {
77
Response.success(req, res, next, (response.code || 200), response.data);
88
}).catch(error => {
99
Response.error(req, res, next, (error.status || 500), error.message);

components/customer/store.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,17 @@ function exist(condition) {
2222
/**
2323
* Method that return a list of customers
2424
*/
25-
function list() {
25+
function list(offset, limit) {
26+
if (offset && limit) {
27+
const statements = {
28+
select: 'name bags',
29+
skip: parseInt(offset),
30+
limit: parseInt(limit)
31+
32+
};
33+
return Store.query(schema, {}, statements, true);
34+
}
35+
2636
return Store.list(schema, {});
2737
}
2838

0 commit comments

Comments
 (0)