@mohasinac/appkit 4.30.3 → 4.30.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.
@@ -8,6 +8,7 @@
8
8
  * export { GET } from "@mohasinac/feat-blog";
9
9
  * ```
10
10
  */
11
+ import { blogRepository } from "../repository/blog.repository";
11
12
  import { NextResponse } from "next/server.js";
12
13
  import { getProviders } from "../../../contracts";
13
14
  import { normalizeError } from "../../../errors/normalize";
@@ -33,9 +34,11 @@ export async function GET(request) {
33
34
  const tags = param(url, "tags");
34
35
  if (tags)
35
36
  parts.push(`tags@=${tags}`);
37
+ // Token search rides OUTSIDE `filters` — array-contains is not expressible
38
+ // in Sieve, and as `title@=*` this was a case-SENSITIVE prefix match on the
39
+ // generic repository path (`base.ts`), so "Beyblade" matched and "beyblade"
40
+ // did not. searchTxt is normalised, so case and accents stop mattering.
36
41
  const q = param(url, "q");
37
- if (q)
38
- parts.push(`title@=*${q}`);
39
42
  const featured = param(url, "featured");
40
43
  if (featured === "true")
41
44
  parts.push("isFeatured==true");
@@ -46,17 +49,19 @@ export async function GET(request) {
46
49
  if (!db) {
47
50
  return NextResponse.json({ success: false, error: "Database provider not registered" }, { status: 503 });
48
51
  }
49
- const repo = db.getRepository("blogPosts");
50
- const result = await repo.findAll({ filters, sort, page, perPage });
52
+ // `blogRepository.listAll` rather than the generic `db.getRepository(...)`:
53
+ // only the feature repository knows how to push a searchTxt clause down and
54
+ // AND-refine the remaining terms.
55
+ const result = await blogRepository.listAll({ filters, sorts: sort, page, pageSize: perPage }, q ? { search: q } : undefined);
51
56
  const meta = {
52
57
  total: result.total,
53
58
  page: result.page,
54
- pageSize: result.perPage,
59
+ pageSize: result.pageSize,
55
60
  totalPages: result.totalPages,
56
- hasMore: result.page < result.totalPages,
61
+ hasMore: result.hasMore,
57
62
  };
58
63
  const body = {
59
- posts: result.data,
64
+ posts: result.items,
60
65
  meta,
61
66
  };
62
67
  return NextResponse.json({ success: true, data: body });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mohasinac/appkit",
3
- "version": "4.30.3",
3
+ "version": "4.30.4",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"