api-paginate 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +0 -15
- package/dist/index.d.ts +0 -15
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +23 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
interface PaginateOptions {
|
|
2
|
-
/** Current page (1-based); use this instead of deprecated page */
|
|
3
2
|
current_page?: number;
|
|
4
|
-
/** Items per page; use this instead of deprecated perPage */
|
|
5
3
|
per_page?: number;
|
|
6
|
-
/** Base URL for link generation; if omitted, uses configured baseUrl or auto-detects in browser */
|
|
7
4
|
baseUrl?: string;
|
|
8
|
-
/** Route/path for links (e.g. '/api/users'). Combines with configured baseUrl or window.origin. */
|
|
9
5
|
route?: string;
|
|
10
|
-
/** @deprecated Use route instead. Path for link generation. */
|
|
11
|
-
path?: string;
|
|
12
|
-
/** Query param name for page (default: 'page') */
|
|
13
6
|
pageParam?: string;
|
|
14
7
|
}
|
|
15
8
|
interface PaginateMeta {
|
|
@@ -43,18 +36,10 @@ interface PaginateRequest {
|
|
|
43
36
|
}
|
|
44
37
|
|
|
45
38
|
interface PaginatorConfig {
|
|
46
|
-
/** Application base URL (origin), e.g. https://myserver.com or http://localhost:3000 */
|
|
47
39
|
baseUrl?: string;
|
|
48
|
-
/** Default route, e.g. /api (used when paginate is called without route) */
|
|
49
40
|
route?: string;
|
|
50
|
-
/** @deprecated Use route instead */
|
|
51
|
-
path?: string;
|
|
52
|
-
/** Default page param name */
|
|
53
41
|
pageParam?: string;
|
|
54
|
-
/** Default per_page */
|
|
55
42
|
per_page?: number;
|
|
56
|
-
/** @deprecated Use per_page instead */
|
|
57
|
-
perPage?: number;
|
|
58
43
|
}
|
|
59
44
|
/**
|
|
60
45
|
* Configure default options once. These are used when not overridden per-call.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
interface PaginateOptions {
|
|
2
|
-
/** Current page (1-based); use this instead of deprecated page */
|
|
3
2
|
current_page?: number;
|
|
4
|
-
/** Items per page; use this instead of deprecated perPage */
|
|
5
3
|
per_page?: number;
|
|
6
|
-
/** Base URL for link generation; if omitted, uses configured baseUrl or auto-detects in browser */
|
|
7
4
|
baseUrl?: string;
|
|
8
|
-
/** Route/path for links (e.g. '/api/users'). Combines with configured baseUrl or window.origin. */
|
|
9
5
|
route?: string;
|
|
10
|
-
/** @deprecated Use route instead. Path for link generation. */
|
|
11
|
-
path?: string;
|
|
12
|
-
/** Query param name for page (default: 'page') */
|
|
13
6
|
pageParam?: string;
|
|
14
7
|
}
|
|
15
8
|
interface PaginateMeta {
|
|
@@ -43,18 +36,10 @@ interface PaginateRequest {
|
|
|
43
36
|
}
|
|
44
37
|
|
|
45
38
|
interface PaginatorConfig {
|
|
46
|
-
/** Application base URL (origin), e.g. https://myserver.com or http://localhost:3000 */
|
|
47
39
|
baseUrl?: string;
|
|
48
|
-
/** Default route, e.g. /api (used when paginate is called without route) */
|
|
49
40
|
route?: string;
|
|
50
|
-
/** @deprecated Use route instead */
|
|
51
|
-
path?: string;
|
|
52
|
-
/** Default page param name */
|
|
53
41
|
pageParam?: string;
|
|
54
|
-
/** Default per_page */
|
|
55
42
|
per_page?: number;
|
|
56
|
-
/** @deprecated Use per_page instead */
|
|
57
|
-
perPage?: number;
|
|
58
43
|
}
|
|
59
44
|
/**
|
|
60
45
|
* Configure default options once. These are used when not overridden per-call.
|
package/dist/index.js
CHANGED
|
@@ -50,7 +50,7 @@ function resolveBaseUrl(options) {
|
|
|
50
50
|
if (typeof opts.baseUrl === "string" && opts.baseUrl.trim()) {
|
|
51
51
|
return opts.baseUrl.trim();
|
|
52
52
|
}
|
|
53
|
-
const path =
|
|
53
|
+
const path = typeof opts.route === "string" ? opts.route : "";
|
|
54
54
|
const pathTrimmed = typeof path === "string" ? path.trim() : "";
|
|
55
55
|
if (pathTrimmed && config.baseUrl) {
|
|
56
56
|
return joinBaseAndPath(config.baseUrl.trim(), pathTrimmed);
|
|
@@ -59,7 +59,7 @@ function resolveBaseUrl(options) {
|
|
|
59
59
|
return joinBaseAndPath(window.location.origin, pathTrimmed);
|
|
60
60
|
}
|
|
61
61
|
if (pathTrimmed) return pathTrimmed;
|
|
62
|
-
const configRoute = config.route
|
|
62
|
+
const configRoute = config.route;
|
|
63
63
|
if (config.baseUrl && configRoute) {
|
|
64
64
|
return joinBaseAndPath(config.baseUrl.trim(), configRoute.trim());
|
|
65
65
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -19,7 +19,7 @@ function resolveBaseUrl(options) {
|
|
|
19
19
|
if (typeof opts.baseUrl === "string" && opts.baseUrl.trim()) {
|
|
20
20
|
return opts.baseUrl.trim();
|
|
21
21
|
}
|
|
22
|
-
const path =
|
|
22
|
+
const path = typeof opts.route === "string" ? opts.route : "";
|
|
23
23
|
const pathTrimmed = typeof path === "string" ? path.trim() : "";
|
|
24
24
|
if (pathTrimmed && config.baseUrl) {
|
|
25
25
|
return joinBaseAndPath(config.baseUrl.trim(), pathTrimmed);
|
|
@@ -28,7 +28,7 @@ function resolveBaseUrl(options) {
|
|
|
28
28
|
return joinBaseAndPath(window.location.origin, pathTrimmed);
|
|
29
29
|
}
|
|
30
30
|
if (pathTrimmed) return pathTrimmed;
|
|
31
|
-
const configRoute = config.route
|
|
31
|
+
const configRoute = config.route;
|
|
32
32
|
if (config.baseUrl && configRoute) {
|
|
33
33
|
return joinBaseAndPath(config.baseUrl.trim(), configRoute.trim());
|
|
34
34
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "api-paginate",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Paginate arrays for Node and browsers. Configure once at app entry (app.ts/server.ts); use paginate/paginateFromRequest in routes. Returns JSON with data, meta, and links.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -12,8 +12,27 @@
|
|
|
12
12
|
"require": "./dist/index.js"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
|
-
"files": [
|
|
16
|
-
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"pagination",
|
|
21
|
+
"array",
|
|
22
|
+
"node",
|
|
23
|
+
"nodejs",
|
|
24
|
+
"api",
|
|
25
|
+
"express",
|
|
26
|
+
"nextjs",
|
|
27
|
+
"react",
|
|
28
|
+
"angular",
|
|
29
|
+
"json",
|
|
30
|
+
"res.json",
|
|
31
|
+
"meta",
|
|
32
|
+
"links",
|
|
33
|
+
"configure",
|
|
34
|
+
"baseUrl"
|
|
35
|
+
],
|
|
17
36
|
"license": "MIT",
|
|
18
37
|
"author": "Kabanda Kpanti Michael <michaelkpantiramp@gmail.com> (https://github.com/Michael-Builds)",
|
|
19
38
|
"repository": {
|
|
@@ -38,6 +57,6 @@
|
|
|
38
57
|
"tailwindcss": "^4",
|
|
39
58
|
"tsup": "^8.0.0",
|
|
40
59
|
"typescript": "^5.0.0",
|
|
41
|
-
"vitest": "^1.0
|
|
60
|
+
"vitest": "^4.1.0"
|
|
42
61
|
}
|
|
43
62
|
}
|