diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-03-05 12:00:39 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-03-05 12:00:39 +0900 |
| commit | 17a23c3eb508bd15bc68999f448224eb7cc64354 (patch) | |
| tree | ef7ece8bf80ea957981856746b30be9beac544af /src/api/endpoints/posts/replies.ts | |
| parent | Clean up :sparkles: (diff) | |
| download | sharkey-17a23c3eb508bd15bc68999f448224eb7cc64354.tar.gz sharkey-17a23c3eb508bd15bc68999f448224eb7cc64354.tar.bz2 sharkey-17a23c3eb508bd15bc68999f448224eb7cc64354.zip | |
Use cafy
Diffstat (limited to 'src/api/endpoints/posts/replies.ts')
| -rw-r--r-- | src/api/endpoints/posts/replies.ts | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/api/endpoints/posts/replies.ts b/src/api/endpoints/posts/replies.ts index 378ba7ec2b..9279cd66f6 100644 --- a/src/api/endpoints/posts/replies.ts +++ b/src/api/endpoints/posts/replies.ts @@ -1,7 +1,7 @@ /** * Module dependencies */ -import it from '../../it'; +import it from 'cafy'; import Post from '../../models/post'; import serialize from '../../serializers/post'; @@ -18,15 +18,15 @@ module.exports = (params, user) => new Promise(async (res, rej) => { if (postIdErr) return rej('invalid post_id param'); // Get 'limit' parameter - const [limit, limitErr] = it(params.limit).expect.number().range(1, 100).default(10).qed(); + const [limit = 10, limitErr] = it(params.limit).expect.number().range(1, 100)).get(); if (limitErr) return rej('invalid limit param'); // Get 'offset' parameter - const [offset, offsetErr] = it(params.offset).expect.number().min(0).default(0).qed(); + const [offset = 0, offsetErr] = it(params.offset).expect.number().min(0).get(); if (offsetErr) return rej('invalid offset param'); // Get 'sort' parameter - const [sort, sortError] = it(params.sort).expect.string().or('desc asc').default('desc').qed(); + const [sort = 'desc', sortError] = it(params.sort).expect.string().or('desc asc').get(); if (sortError) return rej('invalid sort param'); // Lookup post |