Use cafy
This commit is contained in:
@ -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,11 +18,11 @@ 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');
|
||||
|
||||
// Lookup post
|
||||
|
Reference in New Issue
Block a user