xvideosx 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. package/.codeclimate.yml +12 -0
  2. package/.editorconfig +12 -0
  3. package/.eslintignore +0 -0
  4. package/.eslintrc.yml +26 -0
  5. package/.gitattributes +107 -0
  6. package/.github/workflows/node.js.yml +29 -0
  7. package/.travis.yml +13 -0
  8. package/AUTHORS +2 -0
  9. package/CODE_OF_CONDUCT.md +5 -0
  10. package/LICENSE +29 -0
  11. package/README.md +188 -0
  12. package/index.js +1 -0
  13. package/lib/api/base.js +14 -0
  14. package/lib/api/index.js +5 -0
  15. package/lib/api/videos/best/best.js +19 -0
  16. package/lib/api/videos/best/best.spec.js +138 -0
  17. package/lib/api/videos/best/createHasNextFunction.js +10 -0
  18. package/lib/api/videos/best/createHasPreviousFunction.js +10 -0
  19. package/lib/api/videos/best/createNextFunction.js +12 -0
  20. package/lib/api/videos/best/createPreviousFunction.js +12 -0
  21. package/lib/api/videos/best/createRefreshFunction.js +11 -0
  22. package/lib/api/videos/best/index.js +1 -0
  23. package/lib/api/videos/best/parseResponse.js +45 -0
  24. package/lib/api/videos/best/parseVideo.js +27 -0
  25. package/lib/api/videos/dashboard/createHasNextFunction.js +10 -0
  26. package/lib/api/videos/dashboard/createHasPreviousFunction.js +10 -0
  27. package/lib/api/videos/dashboard/createNextFunction.js +12 -0
  28. package/lib/api/videos/dashboard/createPreviousFunction.js +12 -0
  29. package/lib/api/videos/dashboard/createRefreshFunction.js +11 -0
  30. package/lib/api/videos/dashboard/dashboard.js +14 -0
  31. package/lib/api/videos/dashboard/dashboard.spec.js +138 -0
  32. package/lib/api/videos/dashboard/index.js +1 -0
  33. package/lib/api/videos/dashboard/parseResponse.js +45 -0
  34. package/lib/api/videos/dashboard/parseVideo.js +27 -0
  35. package/lib/api/videos/details/details.js +48 -0
  36. package/lib/api/videos/details/details.spec.js +49 -0
  37. package/lib/api/videos/details/index.js +1 -0
  38. package/lib/api/videos/fresh/createHasNextFunction.js +10 -0
  39. package/lib/api/videos/fresh/createHasPreviousFunction.js +10 -0
  40. package/lib/api/videos/fresh/createNextFunction.js +12 -0
  41. package/lib/api/videos/fresh/createPreviousFunction.js +12 -0
  42. package/lib/api/videos/fresh/createRefreshFunction.js +11 -0
  43. package/lib/api/videos/fresh/fresh.js +14 -0
  44. package/lib/api/videos/fresh/fresh.spec.js +138 -0
  45. package/lib/api/videos/fresh/index.js +1 -0
  46. package/lib/api/videos/fresh/parseResponse.js +45 -0
  47. package/lib/api/videos/fresh/parseVideo.js +27 -0
  48. package/lib/api/videos/index.js +8 -0
  49. package/lib/api/videos/search/createHasNextFunction.js +10 -0
  50. package/lib/api/videos/search/createHasPreviousFunction.js +10 -0
  51. package/lib/api/videos/search/createNextFunction.js +12 -0
  52. package/lib/api/videos/search/createPreviousFunction.js +12 -0
  53. package/lib/api/videos/search/createRefreshFunction.js +11 -0
  54. package/lib/api/videos/search/index.js +1 -0
  55. package/lib/api/videos/search/parseResponse.js +45 -0
  56. package/lib/api/videos/search/parseVideo.js +27 -0
  57. package/lib/api/videos/search/search.js +23 -0
  58. package/lib/api/videos/search/search.spec.js +138 -0
  59. package/lib/api/videos/verified/createHasNextFunction.js +10 -0
  60. package/lib/api/videos/verified/createHasPreviousFunction.js +10 -0
  61. package/lib/api/videos/verified/createNextFunction.js +12 -0
  62. package/lib/api/videos/verified/createPreviousFunction.js +12 -0
  63. package/lib/api/videos/verified/createRefreshFunction.js +11 -0
  64. package/lib/api/videos/verified/index.js +1 -0
  65. package/lib/api/videos/verified/parseResponse.js +45 -0
  66. package/lib/api/videos/verified/parseVideo.js +27 -0
  67. package/lib/api/videos/verified/verified.js +14 -0
  68. package/lib/api/videos/verified/verified.spec.js +138 -0
  69. package/lib/index.js +1 -0
  70. package/lib/xvideos.js +1 -0
  71. package/lib/xvideos.spec.js +22 -0
  72. package/package.json +44 -0
@@ -0,0 +1,45 @@
1
+ const cheerio = require('cheerio');
2
+ const parseVideo = require('./parseVideo');
3
+ const createRefreshFunction = require('./createRefreshFunction');
4
+ const createHasNextFunction = require('./createHasNextFunction');
5
+ const createNextFunction = require('./createNextFunction');
6
+ const createHasPreviousFunction = require('./createHasPreviousFunction');
7
+ const createPreviousFunction = require('./createPreviousFunction');
8
+
9
+ const getVideos = ($) => {
10
+ return $('#content > .mozaique > .thumb-block')
11
+ .map((i, video) => parseVideo($, video))
12
+ .get();
13
+ };
14
+
15
+ const getPages = ($) => {
16
+ return $('.pagination > ul > li > a')
17
+ .map((i, page) => $(page)
18
+ .text())
19
+ .filter((i, page) => !isNaN(page))
20
+ .map((i, page) => Number(page))
21
+ .get();
22
+ };
23
+
24
+ const parseResponse = (page, { data }) => {
25
+ const $ = cheerio.load(data);
26
+
27
+ const videos = getVideos($);
28
+
29
+ const pagination = {
30
+ page,
31
+ pages: getPages($),
32
+ };
33
+
34
+ return {
35
+ videos,
36
+ pagination,
37
+ refresh: createRefreshFunction(pagination),
38
+ hasNext: createHasNextFunction(pagination),
39
+ next: createNextFunction(pagination),
40
+ hasPrevious: createHasPreviousFunction(pagination),
41
+ previous: createPreviousFunction(pagination),
42
+ };
43
+ };
44
+
45
+ module.exports = parseResponse;
@@ -0,0 +1,27 @@
1
+ const base = require('../../base');
2
+
3
+ const parseVideo = ($, video) => {
4
+ const $video = $(video);
5
+
6
+ const title = $video.find('p:not(.metadata) a').attr('title');
7
+ const path = $video.find('.thumb > a').attr('href');
8
+ const url = `${base.BASE_URL}${path}`;
9
+ const views = $video.find('p.metadata > span > span:not(.duration)').text();
10
+ const duration = $video.find('p.metadata > span.bg > span.duration').text();
11
+ const profileElement = $video.find('p.metadata > span > a');
12
+ const profile = {
13
+ name: profileElement.text(),
14
+ url: `${base.BASE_URL}${profileElement.attr('href')}`,
15
+ };
16
+
17
+ return {
18
+ url,
19
+ path,
20
+ title,
21
+ duration,
22
+ profile,
23
+ views,
24
+ };
25
+ };
26
+
27
+ module.exports = parseVideo;
@@ -0,0 +1,10 @@
1
+ const hasNextFunction = (currentPage, pages) => () => {
2
+ return currentPage < Math.max(...pages);
3
+ };
4
+
5
+ const createHasNextFunction = (pagination) => {
6
+ const { page, pages } = pagination;
7
+ return hasNextFunction(page, pages);
8
+ };
9
+
10
+ module.exports = createHasNextFunction;
@@ -0,0 +1,10 @@
1
+ const hasPreviousFunction = (currentPage, pages) => () => {
2
+ return currentPage > Math.min(...pages);
3
+ };
4
+
5
+ const createHasPreviousFunction = (pagination) => {
6
+ const { page, pages } = pagination;
7
+ return hasPreviousFunction(page, pages);
8
+ };
9
+
10
+ module.exports = createHasPreviousFunction;
@@ -0,0 +1,12 @@
1
+ const nextFunction = (currentPage) => () => {
2
+ const dashboard = require('./dashboard');
3
+ const next = currentPage + 1;
4
+ return dashboard({ page: next });
5
+ };
6
+
7
+ const createNextFunction = (pagination) => {
8
+ const { page } = pagination;
9
+ return nextFunction(page);
10
+ };
11
+
12
+ module.exports = createNextFunction;
@@ -0,0 +1,12 @@
1
+ const previousFunction = (currentPage) => () => {
2
+ const dashboard = require('./dashboard');
3
+ const previous = currentPage - 1;
4
+ return dashboard({ page: previous });
5
+ };
6
+
7
+ const createPreviousFunction = (pagination) => {
8
+ const { page } = pagination;
9
+ return previousFunction(page);
10
+ };
11
+
12
+ module.exports = createPreviousFunction;
@@ -0,0 +1,11 @@
1
+ const refreshFunction = (currentPage) => () => {
2
+ const dashboard = require('./dashboard');
3
+ return dashboard(currentPage);
4
+ };
5
+
6
+ const createRefreshFunction = (pagination) => {
7
+ const { page } = pagination;
8
+ return refreshFunction(page);
9
+ };
10
+
11
+ module.exports = createRefreshFunction;
@@ -0,0 +1,14 @@
1
+ const base = require('../../base');
2
+ const parseResponse = require('./parseResponse');
3
+
4
+ const PATH = '/verified/videos';
5
+
6
+ const dashboard = async ({ page = 1 } = {}) => {
7
+ if (page < 1 || page > Number.MAX_SAFE_INTEGER) {
8
+ throw new Error(`Invalid page: ${page}`);
9
+ }
10
+ const request = base.createRequest();
11
+ return parseResponse(page, await request.get(`${PATH}/${page === 0 ? '' : page}`));
12
+ };
13
+
14
+ module.exports = dashboard;
@@ -0,0 +1,138 @@
1
+ /* eslint-disable padded-blocks */
2
+
3
+ const chai = require('chai');
4
+ const dashboard = require('./dashboard');
5
+
6
+ before(() => {
7
+ chai.should();
8
+ });
9
+
10
+ describe('api/videos/dashboard', () => {
11
+
12
+ it('should list dashboard video pages', async () => {
13
+ const list = await dashboard({ page: 2 });
14
+
15
+ list.should.be.an('object');
16
+ list.pagination.should.be.an('object');
17
+ list.pagination.page.should.be.equals(2);
18
+ list.pagination.pages.should.be.an('array');
19
+ list.pagination.pages[0].should.be.a('number');
20
+ list.hasNext.should.be.a('function');
21
+ list.hasNext().should.be.equals(true);
22
+ list.hasPrevious.should.be.a('function');
23
+ list.hasPrevious().should.be.equals(true);
24
+ list.next.should.be.a('function');
25
+ list.previous.should.be.a('function');
26
+ list.videos.should.be.an('array');
27
+ list.videos.forEach((video) => {
28
+ video.should.be.an('object');
29
+ video.should.have.ownPropertyDescriptor('duration');
30
+ video.duration.should.be.a('string');
31
+ video.should.have.ownPropertyDescriptor('path');
32
+ video.path.should.be.a('string');
33
+ video.should.have.ownPropertyDescriptor('profile');
34
+ video.profile.should.be.an('object');
35
+ video.profile.should.have.ownPropertyDescriptor('name');
36
+ video.profile.name.should.be.an('string');
37
+ video.profile.should.have.ownPropertyDescriptor('url');
38
+ video.profile.url.should.be.an('string');
39
+ video.should.have.ownPropertyDescriptor('title');
40
+ video.title.should.be.a('string');
41
+ video.should.have.ownPropertyDescriptor('url');
42
+ video.url.should.be.a('string');
43
+ video.should.have.ownPropertyDescriptor('views');
44
+ video.views.should.be.a('string');
45
+ });
46
+
47
+ const previous = await list.previous();
48
+ previous.should.be.an('object');
49
+ previous.pagination.should.be.an('object');
50
+ previous.pagination.page.should.be.equals(1);
51
+ previous.pagination.pages.should.be.an('array');
52
+ previous.pagination.pages[0].should.be.a('number');
53
+ previous.hasNext.should.be.a('function');
54
+ previous.hasNext().should.be.equals(true);
55
+ previous.hasPrevious.should.be.a('function');
56
+ previous.hasPrevious().should.be.equals(false);
57
+ previous.next.should.be.a('function');
58
+ previous.previous.should.be.a('function');
59
+ previous.videos.should.be.an('array');
60
+ previous.videos.forEach((video) => {
61
+ video.should.be.an('object');
62
+ video.should.have.ownPropertyDescriptor('duration');
63
+ video.duration.should.be.a('string');
64
+ video.should.have.ownPropertyDescriptor('path');
65
+ video.path.should.be.a('string');
66
+ video.should.have.ownPropertyDescriptor('profile');
67
+ video.profile.should.be.an('object');
68
+ video.profile.should.have.ownPropertyDescriptor('name');
69
+ video.profile.name.should.be.an('string');
70
+ video.profile.should.have.ownPropertyDescriptor('url');
71
+ video.profile.url.should.be.an('string');
72
+ video.should.have.ownPropertyDescriptor('title');
73
+ video.title.should.be.a('string');
74
+ video.should.have.ownPropertyDescriptor('url');
75
+ video.url.should.be.a('string');
76
+ video.should.have.ownPropertyDescriptor('views');
77
+ video.views.should.be.a('string');
78
+ });
79
+
80
+ const next = await list.next();
81
+ next.should.be.an('object');
82
+ next.pagination.should.be.an('object');
83
+ next.pagination.page.should.be.equals(3);
84
+ next.pagination.pages.should.be.an('array');
85
+ next.pagination.pages[0].should.be.a('number');
86
+ next.hasNext.should.be.a('function');
87
+ next.hasNext().should.be.equals(true);
88
+ next.hasPrevious.should.be.a('function');
89
+ next.hasPrevious().should.be.equals(true);
90
+ next.next.should.be.a('function');
91
+ next.previous.should.be.a('function');
92
+ next.videos.should.be.an('array');
93
+ next.videos.forEach((video) => {
94
+ video.should.be.an('object');
95
+ video.should.have.ownPropertyDescriptor('duration');
96
+ video.duration.should.be.a('string');
97
+ video.should.have.ownPropertyDescriptor('path');
98
+ video.path.should.be.a('string');
99
+ video.should.have.ownPropertyDescriptor('profile');
100
+ video.profile.should.be.an('object');
101
+ video.profile.should.have.ownPropertyDescriptor('name');
102
+ video.profile.name.should.be.an('string');
103
+ video.profile.should.have.ownPropertyDescriptor('url');
104
+ video.profile.url.should.be.an('string');
105
+ video.should.have.ownPropertyDescriptor('title');
106
+ video.title.should.be.a('string');
107
+ video.should.have.ownPropertyDescriptor('url');
108
+ video.url.should.be.a('string');
109
+ video.should.have.ownPropertyDescriptor('views');
110
+ video.views.should.be.a('string');
111
+ });
112
+
113
+ await list.refresh();
114
+ }).timeout(10000);
115
+
116
+ it('should fail when page parameter is beyond limit', async () => {
117
+ let err;
118
+ try {
119
+ await dashboard({ page: Number.MAX_SAFE_INTEGER + 1 });
120
+ } catch (error) {
121
+ err = error;
122
+ } finally {
123
+ err.should.be.an('error');
124
+ }
125
+ }).timeout(10000);
126
+
127
+ it('should fail when page parameter is less than 0', async () => {
128
+ let err;
129
+ try {
130
+ await dashboard({ page: -1 });
131
+ } catch (error) {
132
+ err = error;
133
+ } finally {
134
+ err.should.be.an('error');
135
+ }
136
+ }).timeout(10000);
137
+
138
+ });
@@ -0,0 +1 @@
1
+ module.exports = require('./dashboard');
@@ -0,0 +1,45 @@
1
+ const cheerio = require('cheerio');
2
+ const parseVideo = require('./parseVideo');
3
+ const createRefreshFunction = require('./createRefreshFunction');
4
+ const createHasNextFunction = require('./createHasNextFunction');
5
+ const createNextFunction = require('./createNextFunction');
6
+ const createHasPreviousFunction = require('./createHasPreviousFunction');
7
+ const createPreviousFunction = require('./createPreviousFunction');
8
+
9
+ const getVideos = ($) => {
10
+ return $('#content > .mozaique > .thumb-block')
11
+ .map((i, video) => parseVideo($, video))
12
+ .get();
13
+ };
14
+
15
+ const getPages = ($) => {
16
+ return $('.pagination > ul > li > a')
17
+ .map((i, page) => $(page)
18
+ .text())
19
+ .filter((i, page) => !isNaN(page))
20
+ .map((i, page) => Number(page))
21
+ .get();
22
+ };
23
+
24
+ const parseResponse = (page, { data }) => {
25
+ const $ = cheerio.load(data);
26
+
27
+ const videos = getVideos($);
28
+
29
+ const pagination = {
30
+ page,
31
+ pages: getPages($),
32
+ };
33
+
34
+ return {
35
+ videos,
36
+ pagination,
37
+ refresh: createRefreshFunction(pagination),
38
+ hasNext: createHasNextFunction(pagination),
39
+ next: createNextFunction(pagination),
40
+ hasPrevious: createHasPreviousFunction(pagination),
41
+ previous: createPreviousFunction(pagination),
42
+ };
43
+ };
44
+
45
+ module.exports = parseResponse;
@@ -0,0 +1,27 @@
1
+ const base = require('../../base');
2
+
3
+ const parseVideo = ($, video) => {
4
+ const $video = $(video);
5
+
6
+ const title = $video.find('p:not(.metadata) a').attr('title');
7
+ const path = $video.find('.thumb > a').attr('href');
8
+ const url = `${base.BASE_URL}${path}`;
9
+ const views = $video.find('p.metadata > span > span:not(.duration)').text();
10
+ const duration = $video.find('p.metadata > span.bg > span.duration').text();
11
+ const profileElement = $video.find('p.metadata > span > a');
12
+ const profile = {
13
+ name: profileElement.text(),
14
+ url: `${base.BASE_URL}${profileElement.attr('href')}`,
15
+ };
16
+
17
+ return {
18
+ url,
19
+ path,
20
+ title,
21
+ duration,
22
+ profile,
23
+ views,
24
+ };
25
+ };
26
+
27
+ module.exports = parseVideo;
@@ -0,0 +1,48 @@
1
+ const cheerio = require('cheerio');
2
+ const puppeteer = require('puppeteer');
3
+
4
+ const details = async ({ url, puppeteerConfig } = {}) => {
5
+ let browser;
6
+ try {
7
+ browser = await puppeteer.launch(puppeteerConfig);
8
+ const page = await browser.newPage();
9
+ await page.goto(url, { waitUntil: 'networkidle2' });
10
+ const html = await page.content();
11
+
12
+ const $ = cheerio.load(html);
13
+
14
+ const title = $('meta[property="og:title"]').attr('content');
15
+ const duration = $('meta[property="og:duration"]').attr('content');
16
+ const image = $('meta[property="og:image"]').attr('content');
17
+ const videoType = $('meta[property="og:video:type"]').attr('content');
18
+ const videoWidth = $('meta[property="og:video:width"]').attr('content');
19
+ const videoHeight = $('meta[property="og:video:height"]').attr('content');
20
+ const views = $('#nb-views-number').text();
21
+ const videoScript = $('#video-player-bg > script:nth-child(6)').html();
22
+ const files = {
23
+ low: (videoScript.match('html5player.setVideoUrlLow\\(\'(.*?)\'\\);') || [])[1],
24
+ high: videoScript.match('html5player.setVideoUrlHigh\\(\'(.*?)\'\\);' || [])[1],
25
+ HLS: videoScript.match('html5player.setVideoHLS\\(\'(.*?)\'\\);' || [])[1],
26
+ thumb: videoScript.match('html5player.setThumbUrl\\(\'(.*?)\'\\);' || [])[1],
27
+ thumb69: videoScript.match('html5player.setThumbUrl169\\(\'(.*?)\'\\);' || [])[1],
28
+ thumbSlide: videoScript.match('html5player.setThumbSlide\\(\'(.*?)\'\\);' || [])[1],
29
+ thumbSlideBig: videoScript.match('html5player.setThumbSlideBig\\(\'(.*?)\'\\);' || [])[1],
30
+ };
31
+
32
+ return {
33
+ title,
34
+ url,
35
+ duration,
36
+ image,
37
+ views,
38
+ videoType,
39
+ videoWidth,
40
+ videoHeight,
41
+ files,
42
+ };
43
+ } finally {
44
+ if (browser) await browser.close();
45
+ }
46
+ };
47
+
48
+ module.exports = details;
@@ -0,0 +1,49 @@
1
+ /* eslint-disable padded-blocks */
2
+
3
+ const chai = require('chai');
4
+ const details = require('./details');
5
+ const dashboard = require('../dashboard');
6
+
7
+ before(() => {
8
+ chai.should();
9
+ });
10
+
11
+ describe('api/videos/details', () => {
12
+
13
+ it('should retrieve video details', async () => {
14
+ const { videos } = await dashboard();
15
+
16
+ const video = await details(videos[0]);
17
+
18
+ video.should.be.an('object');
19
+ video.should.have.ownPropertyDescriptor('duration');
20
+ video.duration.should.be.a('string');
21
+ video.should.have.ownPropertyDescriptor('files');
22
+ video.files.should.be.an('object');
23
+ video.files.should.have.ownPropertyDescriptor('HLS');
24
+ video.files.HLS.should.be.a('string');
25
+ video.files.should.have.ownPropertyDescriptor('high');
26
+ video.files.high.should.be.a('string');
27
+ video.files.should.have.ownPropertyDescriptor('low');
28
+ video.files.low.should.be.a('string');
29
+ video.files.should.have.ownPropertyDescriptor('thumb');
30
+ video.files.thumb.should.be.a('string');
31
+ video.files.should.have.ownPropertyDescriptor('thumb69');
32
+ video.files.thumb69.should.be.a('string');
33
+ video.files.should.have.ownPropertyDescriptor('thumbSlide');
34
+ video.files.thumbSlide.should.be.a('string');
35
+ video.files.should.have.ownPropertyDescriptor('thumbSlideBig');
36
+ video.files.thumbSlideBig.should.be.a('string');
37
+ video.should.have.ownPropertyDescriptor('image');
38
+ video.image.should.be.a('string');
39
+ video.should.have.ownPropertyDescriptor('videoHeight');
40
+ video.videoHeight.should.be.a('string');
41
+ video.should.have.ownPropertyDescriptor('videoType');
42
+ video.videoType.should.be.a('string');
43
+ video.should.have.ownPropertyDescriptor('videoWidth');
44
+ video.videoWidth.should.be.a('string');
45
+ video.should.have.ownPropertyDescriptor('views');
46
+ video.views.should.be.a('string');
47
+ }).timeout(100000);
48
+
49
+ });
@@ -0,0 +1 @@
1
+ module.exports = require('./details');
@@ -0,0 +1,10 @@
1
+ const hasNextFunction = (currentPage, pages) => () => {
2
+ return currentPage < Math.max(...pages);
3
+ };
4
+
5
+ const createHasNextFunction = (pagination) => {
6
+ const { page, pages } = pagination;
7
+ return hasNextFunction(page, pages);
8
+ };
9
+
10
+ module.exports = createHasNextFunction;
@@ -0,0 +1,10 @@
1
+ const hasPreviousFunction = (currentPage, pages) => () => {
2
+ return currentPage > Math.min(...pages);
3
+ };
4
+
5
+ const createHasPreviousFunction = (pagination) => {
6
+ const { page, pages } = pagination;
7
+ return hasPreviousFunction(page, pages);
8
+ };
9
+
10
+ module.exports = createHasPreviousFunction;
@@ -0,0 +1,12 @@
1
+ const nextFunction = (currentPage) => () => {
2
+ const fresh = require('./fresh');
3
+ const next = currentPage + 1;
4
+ return fresh({ page: next });
5
+ };
6
+
7
+ const createNextFunction = (pagination) => {
8
+ const { page } = pagination;
9
+ return nextFunction(page);
10
+ };
11
+
12
+ module.exports = createNextFunction;
@@ -0,0 +1,12 @@
1
+ const previousFunction = (currentPage) => () => {
2
+ const fresh = require('./fresh');
3
+ const previous = currentPage - 1;
4
+ return fresh({ page: previous });
5
+ };
6
+
7
+ const createPreviousFunction = (pagination) => {
8
+ const { page } = pagination;
9
+ return previousFunction(page);
10
+ };
11
+
12
+ module.exports = createPreviousFunction;
@@ -0,0 +1,11 @@
1
+ const refreshFunction = (currentPage) => () => {
2
+ const fresh = require('./fresh');
3
+ return fresh(currentPage);
4
+ };
5
+
6
+ const createRefreshFunction = (pagination) => {
7
+ const { page } = pagination;
8
+ return refreshFunction(page);
9
+ };
10
+
11
+ module.exports = createRefreshFunction;
@@ -0,0 +1,14 @@
1
+ const base = require('../../base');
2
+ const parseResponse = require('./parseResponse');
3
+
4
+ const PATH = '/new';
5
+
6
+ const fresh = async ({ page = 1 } = {}) => {
7
+ if (page < 1 || page > Number.MAX_SAFE_INTEGER) {
8
+ throw new Error(`Invalid page: ${page}`);
9
+ }
10
+ const request = base.createRequest();
11
+ return parseResponse(page, await request.get(`${PATH}/${page}`));
12
+ };
13
+
14
+ module.exports = fresh;