@vitnode/blog 1.2.0-canary.75 → 1.2.0-canary.76

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.
Files changed (153) hide show
  1. package/dist/src/api/modules/admin/admin.module.d.ts +180 -177
  2. package/dist/src/api/modules/admin/admin.module.d.ts.map +1 -1
  3. package/dist/src/api/modules/admin/admin.module.js +2 -1
  4. package/dist/src/api/modules/admin/admin.module.js.map +1 -0
  5. package/dist/src/api/modules/admin/categories/categories.admin.module.d.ts +80 -77
  6. package/dist/src/api/modules/admin/categories/categories.admin.module.d.ts.map +1 -1
  7. package/dist/src/api/modules/admin/categories/categories.admin.module.js +2 -1
  8. package/dist/src/api/modules/admin/categories/categories.admin.module.js.map +1 -0
  9. package/dist/src/api/modules/admin/categories/routes/create.route.d.ts +34 -31
  10. package/dist/src/api/modules/admin/categories/routes/create.route.d.ts.map +1 -1
  11. package/dist/src/api/modules/admin/categories/routes/create.route.js +2 -1
  12. package/dist/src/api/modules/admin/categories/routes/create.route.js.map +1 -0
  13. package/dist/src/api/modules/admin/categories/routes/delete.route.d.ts +18 -15
  14. package/dist/src/api/modules/admin/categories/routes/delete.route.d.ts.map +1 -1
  15. package/dist/src/api/modules/admin/categories/routes/delete.route.js +2 -1
  16. package/dist/src/api/modules/admin/categories/routes/delete.route.js.map +1 -0
  17. package/dist/src/api/modules/admin/categories/routes/edit.route.d.ts +38 -35
  18. package/dist/src/api/modules/admin/categories/routes/edit.route.d.ts.map +1 -1
  19. package/dist/src/api/modules/admin/categories/routes/edit.route.js +2 -1
  20. package/dist/src/api/modules/admin/categories/routes/edit.route.js.map +1 -0
  21. package/dist/src/api/modules/admin/posts/posts.admin.module.d.ts +93 -90
  22. package/dist/src/api/modules/admin/posts/posts.admin.module.d.ts.map +1 -1
  23. package/dist/src/api/modules/admin/posts/posts.admin.module.js +2 -1
  24. package/dist/src/api/modules/admin/posts/posts.admin.module.js.map +1 -0
  25. package/dist/src/api/modules/admin/posts/routes/create.route.d.ts +44 -41
  26. package/dist/src/api/modules/admin/posts/routes/create.route.d.ts.map +1 -1
  27. package/dist/src/api/modules/admin/posts/routes/create.route.js +2 -1
  28. package/dist/src/api/modules/admin/posts/routes/create.route.js.map +1 -0
  29. package/dist/src/api/modules/admin/posts/routes/delete.route.d.ts +18 -15
  30. package/dist/src/api/modules/admin/posts/routes/delete.route.d.ts.map +1 -1
  31. package/dist/src/api/modules/admin/posts/routes/delete.route.js +2 -1
  32. package/dist/src/api/modules/admin/posts/routes/delete.route.js.map +1 -0
  33. package/dist/src/api/modules/admin/posts/routes/edit.route.d.ts +43 -40
  34. package/dist/src/api/modules/admin/posts/routes/edit.route.d.ts.map +1 -1
  35. package/dist/src/api/modules/admin/posts/routes/edit.route.js +2 -1
  36. package/dist/src/api/modules/admin/posts/routes/edit.route.js.map +1 -0
  37. package/dist/src/api/modules/categories/categories.module.d.ts +64 -61
  38. package/dist/src/api/modules/categories/categories.module.d.ts.map +1 -1
  39. package/dist/src/api/modules/categories/categories.module.js +2 -1
  40. package/dist/src/api/modules/categories/categories.module.js.map +1 -0
  41. package/dist/src/api/modules/categories/routes/get.route.d.ts +45 -42
  42. package/dist/src/api/modules/categories/routes/get.route.d.ts.map +1 -1
  43. package/dist/src/api/modules/categories/routes/get.route.js +2 -1
  44. package/dist/src/api/modules/categories/routes/get.route.js.map +1 -0
  45. package/dist/src/api/modules/categories/test.route.d.ts +23 -20
  46. package/dist/src/api/modules/categories/test.route.d.ts.map +1 -1
  47. package/dist/src/api/modules/categories/test.route.js +2 -1
  48. package/dist/src/api/modules/categories/test.route.js.map +1 -0
  49. package/dist/src/api/modules/posts/posts.module.d.ts +54 -51
  50. package/dist/src/api/modules/posts/posts.module.d.ts.map +1 -1
  51. package/dist/src/api/modules/posts/posts.module.js +2 -1
  52. package/dist/src/api/modules/posts/posts.module.js.map +1 -0
  53. package/dist/src/api/modules/posts/routes/get.route.d.ts +64 -61
  54. package/dist/src/api/modules/posts/routes/get.route.d.ts.map +1 -1
  55. package/dist/src/api/modules/posts/routes/get.route.js +2 -1
  56. package/dist/src/api/modules/posts/routes/get.route.js.map +1 -0
  57. package/dist/src/config.api.d.ts +4 -1
  58. package/dist/src/config.api.d.ts.map +1 -1
  59. package/dist/src/config.api.js +2 -1
  60. package/dist/src/config.api.js.map +1 -0
  61. package/dist/src/config.d.ts +4 -1
  62. package/dist/src/config.d.ts.map +1 -1
  63. package/dist/src/config.js +2 -1
  64. package/dist/src/config.js.map +1 -0
  65. package/dist/src/const.d.ts +5 -2
  66. package/dist/src/const.d.ts.map +1 -1
  67. package/dist/src/const.js +2 -1
  68. package/dist/src/const.js.map +1 -0
  69. package/dist/src/database/categories.d.ts +98 -95
  70. package/dist/src/database/categories.d.ts.map +1 -1
  71. package/dist/src/database/categories.js +2 -1
  72. package/dist/src/database/categories.js.map +1 -0
  73. package/dist/src/database/index.d.ts +4 -4
  74. package/dist/src/database/index.js +1 -1
  75. package/dist/src/database/posts.d.ts +132 -129
  76. package/dist/src/database/posts.d.ts.map +1 -1
  77. package/dist/src/database/posts.js +2 -1
  78. package/dist/src/database/posts.js.map +1 -0
  79. package/dist/src/database/relations.d.ts +7 -4
  80. package/dist/src/database/relations.d.ts.map +1 -1
  81. package/dist/src/database/relations.js +2 -1
  82. package/dist/src/database/relations.js.map +1 -0
  83. package/dist/src/emails/test-template.d.ts +20 -18
  84. package/dist/src/emails/test-template.d.ts.map +1 -1
  85. package/dist/src/emails/test-template.js +2 -1
  86. package/dist/src/emails/test-template.js.map +1 -0
  87. package/dist/src/routes/admin/blog/categories/page.d.ts +7 -5
  88. package/dist/src/routes/admin/blog/categories/page.d.ts.map +1 -1
  89. package/dist/src/routes/admin/blog/categories/page.js +2 -1
  90. package/dist/src/routes/admin/blog/categories/page.js.map +1 -0
  91. package/dist/src/routes/admin/blog/posts/page.d.ts +7 -5
  92. package/dist/src/routes/admin/blog/posts/page.d.ts.map +1 -1
  93. package/dist/src/routes/admin/blog/posts/page.js +2 -1
  94. package/dist/src/routes/admin/blog/posts/page.js.map +1 -0
  95. package/dist/src/views/admin/categories/actions/actions.d.ts +4 -1
  96. package/dist/src/views/admin/categories/actions/actions.d.ts.map +1 -1
  97. package/dist/src/views/admin/categories/actions/actions.js +2 -1
  98. package/dist/src/views/admin/categories/actions/actions.js.map +1 -0
  99. package/dist/src/views/admin/categories/actions/create-edit/create-edit.d.ts +8 -5
  100. package/dist/src/views/admin/categories/actions/create-edit/create-edit.d.ts.map +1 -1
  101. package/dist/src/views/admin/categories/actions/create-edit/create-edit.js +2 -1
  102. package/dist/src/views/admin/categories/actions/create-edit/create-edit.js.map +1 -0
  103. package/dist/src/views/admin/categories/actions/create-edit/mutation-api.d.ts +10 -7
  104. package/dist/src/views/admin/categories/actions/create-edit/mutation-api.d.ts.map +1 -1
  105. package/dist/src/views/admin/categories/actions/create-edit/mutation-api.js +2 -1
  106. package/dist/src/views/admin/categories/actions/create-edit/mutation-api.js.map +1 -0
  107. package/dist/src/views/admin/categories/table/actions/delete/delete-action.d.ts +6 -3
  108. package/dist/src/views/admin/categories/table/actions/delete/delete-action.d.ts.map +1 -1
  109. package/dist/src/views/admin/categories/table/actions/delete/delete-action.js +2 -1
  110. package/dist/src/views/admin/categories/table/actions/delete/delete-action.js.map +1 -0
  111. package/dist/src/views/admin/categories/table/actions/delete/mutation-api.d.ts +5 -2
  112. package/dist/src/views/admin/categories/table/actions/delete/mutation-api.d.ts.map +1 -1
  113. package/dist/src/views/admin/categories/table/actions/delete/mutation-api.js +2 -1
  114. package/dist/src/views/admin/categories/table/actions/delete/mutation-api.js.map +1 -0
  115. package/dist/src/views/admin/categories/table/actions/edit-action.d.ts +8 -5
  116. package/dist/src/views/admin/categories/table/actions/edit-action.d.ts.map +1 -1
  117. package/dist/src/views/admin/categories/table/actions/edit-action.js +2 -1
  118. package/dist/src/views/admin/categories/table/actions/edit-action.js.map +1 -0
  119. package/dist/src/views/admin/categories/table/categories-admin-view.d.ts +5 -2
  120. package/dist/src/views/admin/categories/table/categories-admin-view.d.ts.map +1 -1
  121. package/dist/src/views/admin/categories/table/categories-admin-view.js +2 -1
  122. package/dist/src/views/admin/categories/table/categories-admin-view.js.map +1 -0
  123. package/dist/src/views/admin/posts/actions/actions.d.ts +4 -1
  124. package/dist/src/views/admin/posts/actions/actions.d.ts.map +1 -1
  125. package/dist/src/views/admin/posts/actions/actions.js +2 -1
  126. package/dist/src/views/admin/posts/actions/actions.js.map +1 -0
  127. package/dist/src/views/admin/posts/actions/create-edit/create-edit.d.ts +8 -5
  128. package/dist/src/views/admin/posts/actions/create-edit/create-edit.d.ts.map +1 -1
  129. package/dist/src/views/admin/posts/actions/create-edit/create-edit.js +2 -1
  130. package/dist/src/views/admin/posts/actions/create-edit/create-edit.js.map +1 -0
  131. package/dist/src/views/admin/posts/actions/create-edit/mutation-api.d.ts +10 -7
  132. package/dist/src/views/admin/posts/actions/create-edit/mutation-api.d.ts.map +1 -1
  133. package/dist/src/views/admin/posts/actions/create-edit/mutation-api.js +2 -1
  134. package/dist/src/views/admin/posts/actions/create-edit/mutation-api.js.map +1 -0
  135. package/dist/src/views/admin/posts/table/actions/delete/delete-action.d.ts +6 -3
  136. package/dist/src/views/admin/posts/table/actions/delete/delete-action.d.ts.map +1 -1
  137. package/dist/src/views/admin/posts/table/actions/delete/delete-action.js +2 -1
  138. package/dist/src/views/admin/posts/table/actions/delete/delete-action.js.map +1 -0
  139. package/dist/src/views/admin/posts/table/actions/delete/mutation-api.d.ts +5 -2
  140. package/dist/src/views/admin/posts/table/actions/delete/mutation-api.d.ts.map +1 -1
  141. package/dist/src/views/admin/posts/table/actions/delete/mutation-api.js +2 -1
  142. package/dist/src/views/admin/posts/table/actions/delete/mutation-api.js.map +1 -0
  143. package/dist/src/views/admin/posts/table/actions/edit-action.d.ts +8 -5
  144. package/dist/src/views/admin/posts/table/actions/edit-action.d.ts.map +1 -1
  145. package/dist/src/views/admin/posts/table/actions/edit-action.js +2 -1
  146. package/dist/src/views/admin/posts/table/actions/edit-action.js.map +1 -0
  147. package/dist/src/views/admin/posts/table/posts-admin-view.d.ts +5 -2
  148. package/dist/src/views/admin/posts/table/posts-admin-view.d.ts.map +1 -1
  149. package/dist/src/views/admin/posts/table/posts-admin-view.js +2 -1
  150. package/dist/src/views/admin/posts/table/posts-admin-view.js.map +1 -0
  151. package/package.json +6 -8
  152. package/tsconfig.build.json +5 -0
  153. package/dist/src/database/index.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.route.js","names":[],"sources":["../../../../../../../src/api/modules/admin/posts/routes/create.route.ts"],"sourcesContent":["import { z } from \"@hono/zod-openapi\";\nimport { buildRoute } from \"@vitnode/core/api/lib/route\";\nimport { removeSpecialCharacters } from \"@vitnode/core/lib/special-characters\";\nimport { eq } from \"drizzle-orm\";\nimport { HTTPException } from \"hono/http-exception\";\n\nimport { CONFIG_PLUGIN } from \"@/const\";\nimport { blog_categories } from \"@/database/categories\";\nimport { blog_posts } from \"@/database/posts\";\n\nconst zodPostResponseSchema = z.object({\n id: z.number(),\n title: z.string(),\n titleSeo: z.string(),\n content: z.string(),\n categoryId: z.number(),\n createdAt: z.date(),\n updatedAt: z.date(),\n});\n\nexport const zodCreatePostSchema = z.object({\n title: z\n .string()\n .min(3, \"Title must be at least 3 characters long\")\n .max(255, \"Title must not exceed 255 characters\"),\n content: z.string(),\n categoryId: z.number(),\n});\n\nexport const createPostRoute = buildRoute({\n pluginId: CONFIG_PLUGIN.pluginId,\n adminStaffPermission: { module: \"posts\", permission: \"can_create\" },\n route: {\n method: \"post\",\n path: \"/\",\n request: {\n body: {\n content: {\n \"application/json\": {\n schema: zodCreatePostSchema,\n },\n },\n },\n },\n responses: {\n 201: {\n content: {\n \"application/json\": {\n schema: zodPostResponseSchema,\n },\n },\n description: \"Post created successfully\",\n },\n 400: {\n description: \"Bad request - Invalid input data\",\n },\n 404: {\n description: \"Category not found\",\n },\n },\n },\n handler: async c => {\n const { title, content, categoryId } = c.req.valid(\"json\");\n const titleSeo = removeSpecialCharacters(title);\n\n // Check if category exists\n const [category] = await c\n .get(\"db\")\n .select({ id: blog_categories.id })\n .from(blog_categories)\n .where(eq(blog_categories.id, categoryId))\n .limit(1);\n\n if (!category) {\n throw new HTTPException(404, {\n message: \"Category not found.\",\n });\n }\n\n // Check if title SEO already exists\n const [titleSEODuplicate] = await c\n .get(\"db\")\n .select({ titleSeo: blog_posts.titleSeo })\n .from(blog_posts)\n .where(eq(blog_posts.titleSeo, titleSeo))\n .limit(1);\n\n if (titleSEODuplicate?.titleSeo === titleSeo) {\n throw new HTTPException(400, {\n message: \"Post with this title already exists.\",\n });\n }\n\n const [post] = await c\n .get(\"db\")\n .insert(blog_posts)\n .values({\n title,\n titleSeo,\n content,\n categoryId,\n })\n .returning();\n\n return c.json(post, 201);\n },\n});\n"],"mappings":"icAUA,MAAM,EAAwB,EAAE,OAAO,CACrC,GAAI,EAAE,OAAO,EACb,MAAO,EAAE,OAAO,EAChB,SAAU,EAAE,OAAO,EACnB,QAAS,EAAE,OAAO,EAClB,WAAY,EAAE,OAAO,EACrB,UAAW,EAAE,KAAK,EAClB,UAAW,EAAE,KAAK,CACpB,CAAC,EAEY,EAAsB,EAAE,OAAO,CAC1C,MAAO,EACJ,OAAO,CAAC,CACR,IAAI,EAAG,0CAA0C,CAAC,CAClD,IAAI,IAAK,sCAAsC,EAClD,QAAS,EAAE,OAAO,EAClB,WAAY,EAAE,OAAO,CACvB,CAAC,EAEY,EAAkB,EAAW,CACxC,SAAU,EAAc,SACxB,qBAAsB,CAAE,OAAQ,QAAS,WAAY,YAAa,EAClE,MAAO,CACL,OAAQ,OACR,KAAM,IACN,QAAS,CACP,KAAM,CACJ,QAAS,CACP,mBAAoB,CAClB,OAAQ,CACV,CACF,CACF,CACF,EACA,UAAW,CACT,IAAK,CACH,QAAS,CACP,mBAAoB,CAClB,OAAQ,CACV,CACF,EACA,YAAa,2BACf,EACA,IAAK,CACH,YAAa,kCACf,EACA,IAAK,CACH,YAAa,oBACf,CACF,CACF,EACA,QAAS,KAAM,IAAK,CAClB,GAAM,CAAE,QAAO,UAAS,cAAe,EAAE,IAAI,MAAM,MAAM,EACnD,EAAW,EAAwB,CAAK,EAGxC,CAAC,GAAY,MAAM,EACtB,IAAI,IAAI,CAAC,CACT,OAAO,CAAE,GAAI,EAAgB,EAAG,CAAC,CAAC,CAClC,KAAK,CAAe,CAAC,CACrB,MAAM,EAAG,EAAgB,GAAI,CAAU,CAAC,CAAC,CACzC,MAAM,CAAC,EAEV,GAAI,CAAC,EACH,MAAM,IAAI,EAAc,IAAK,CAC3B,QAAS,qBACX,CAAC,EAIH,GAAM,CAAC,GAAqB,MAAM,EAC/B,IAAI,IAAI,CAAC,CACT,OAAO,CAAE,SAAU,EAAW,QAAS,CAAC,CAAC,CACzC,KAAK,CAAU,CAAC,CAChB,MAAM,EAAG,EAAW,SAAU,CAAQ,CAAC,CAAC,CACxC,MAAM,CAAC,EAEV,GAAI,GAAmB,WAAa,EAClC,MAAM,IAAI,EAAc,IAAK,CAC3B,QAAS,sCACX,CAAC,EAGH,GAAM,CAAC,GAAQ,MAAM,EAClB,IAAI,IAAI,CAAC,CACT,OAAO,CAAU,CAAC,CAClB,OAAO,CACN,QACA,WACA,UACA,YACF,CAAC,CAAC,CACD,UAAU,EAEb,OAAO,EAAE,KAAK,EAAM,GAAG,CACzB,CACF,CAAC"}
@@ -1,21 +1,24 @@
1
1
  import { z } from "@hono/zod-openapi";
2
- export declare const deletePostRoute: import("@vitnode/core/api/lib/route").Route<"@vitnode/blog", {
3
- method: "delete";
4
- path: "/{id}";
5
- request: {
6
- params: z.ZodObject<{
7
- id: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
8
- }, z.core.$strip>;
2
+ //#region src/api/modules/admin/posts/routes/delete.route.d.ts
3
+ declare const deletePostRoute: import("@vitnode/core/api/lib/route").Route<"@vitnode/blog", {
4
+ method: "delete";
5
+ path: "/{id}";
6
+ request: {
7
+ params: z.ZodObject<{
8
+ id: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
9
+ }, z.core.$strip>;
10
+ };
11
+ responses: {
12
+ 204: {
13
+ description: string;
9
14
  };
10
- responses: {
11
- 204: {
12
- description: string;
13
- };
14
- 404: {
15
- description: string;
16
- };
15
+ 404: {
16
+ description: string;
17
17
  };
18
+ };
18
19
  } & {
19
- path: string;
20
+ path: string;
20
21
  }>;
22
+ //#endregion
23
+ export { deletePostRoute };
21
24
  //# sourceMappingURL=delete.route.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"delete.route.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/modules/admin/posts/routes/delete.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAQtC,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;EAmC1B,CAAC"}
1
+ {"version":3,"file":"delete.route.d.ts","names":[],"sources":["../../../../../../../src/api/modules/admin/posts/routes/delete.route.ts"],"mappings":";;cAQa,uDAAe"}
@@ -1 +1,2 @@
1
- import{z}from"@hono/zod-openapi";import{buildRoute}from"@vitnode/core/api/lib/route";import{eq}from"drizzle-orm";import{HTTPException}from"hono/http-exception";import{CONFIG_PLUGIN}from"../../../../../const.js";import{blog_posts}from"../../../../../database/posts.js";export const deletePostRoute=buildRoute({pluginId:CONFIG_PLUGIN.pluginId,adminStaffPermission:{module:"posts",permission:"can_delete"},route:{method:"delete",path:"/{id}",request:{params:z.object({id:z.string().transform(Number)})},responses:{204:{description:"Post deleted successfully"},404:{description:"Post not found"}}},handler:async c=>{const{id}=c.req.valid("param");const result=await c.get("db").delete(blog_posts).where(eq(blog_posts.id,id)).returning();if(result.length===0){throw new HTTPException(404)}return c.body(null,204)}});
1
+ import{CONFIG_PLUGIN as e}from"../../../../../const.js";import{blog_posts as t}from"../../../../../database/posts.js";import{z as n}from"@hono/zod-openapi";import{buildRoute as r}from"@vitnode/core/api/lib/route";import{eq as i}from"drizzle-orm";import{HTTPException as a}from"hono/http-exception";const o=r({pluginId:e.pluginId,adminStaffPermission:{module:`posts`,permission:`can_delete`},route:{method:`delete`,path:`/{id}`,request:{params:n.object({id:n.string().transform(Number)})},responses:{204:{description:`Post deleted successfully`},404:{description:`Post not found`}}},handler:async e=>{let{id:n}=e.req.valid(`param`);if((await e.get(`db`).delete(t).where(i(t.id,n)).returning()).length===0)throw new a(404);return e.body(null,204)}});export{o as deletePostRoute};
2
+ //# sourceMappingURL=delete.route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.route.js","names":[],"sources":["../../../../../../../src/api/modules/admin/posts/routes/delete.route.ts"],"sourcesContent":["import { z } from \"@hono/zod-openapi\";\nimport { buildRoute } from \"@vitnode/core/api/lib/route\";\nimport { eq } from \"drizzle-orm\";\nimport { HTTPException } from \"hono/http-exception\";\n\nimport { CONFIG_PLUGIN } from \"@/const\";\nimport { blog_posts } from \"@/database/posts\";\n\nexport const deletePostRoute = buildRoute({\n pluginId: CONFIG_PLUGIN.pluginId,\n adminStaffPermission: { module: \"posts\", permission: \"can_delete\" },\n route: {\n method: \"delete\",\n path: \"/{id}\",\n request: {\n params: z.object({\n id: z.string().transform(Number),\n }),\n },\n responses: {\n 204: {\n description: \"Post deleted successfully\",\n },\n 404: {\n description: \"Post not found\",\n },\n },\n },\n handler: async c => {\n const { id } = c.req.valid(\"param\");\n\n const result = await c\n .get(\"db\")\n .delete(blog_posts)\n .where(eq(blog_posts.id, id))\n .returning();\n\n if (result.length === 0) {\n throw new HTTPException(404);\n }\n\n return c.body(null, 204);\n },\n});\n"],"mappings":"0SAQA,MAAa,EAAkB,EAAW,CACxC,SAAU,EAAc,SACxB,qBAAsB,CAAE,OAAQ,QAAS,WAAY,YAAa,EAClE,MAAO,CACL,OAAQ,SACR,KAAM,QACN,QAAS,CACP,OAAQ,EAAE,OAAO,CACf,GAAI,EAAE,OAAO,CAAC,CAAC,UAAU,MAAM,CACjC,CAAC,CACH,EACA,UAAW,CACT,IAAK,CACH,YAAa,2BACf,EACA,IAAK,CACH,YAAa,gBACf,CACF,CACF,EACA,QAAS,KAAM,IAAK,CAClB,GAAM,CAAE,MAAO,EAAE,IAAI,MAAM,OAAO,EAQlC,IAAI,MANiB,EAClB,IAAI,IAAI,CAAC,CACT,OAAO,CAAU,CAAC,CAClB,MAAM,EAAG,EAAW,GAAI,CAAE,CAAC,CAAC,CAC5B,UAAU,EAAA,CAEF,SAAW,EACpB,MAAM,IAAI,EAAc,GAAG,EAG7B,OAAO,EAAE,KAAK,KAAM,GAAG,CACzB,CACF,CAAC"}
@@ -1,48 +1,51 @@
1
1
  import { z } from "@hono/zod-openapi";
2
- export declare const editPostRoute: import("@vitnode/core/api/lib/route").Route<"@vitnode/blog", {
3
- method: "put";
4
- path: "/{id}";
5
- request: {
6
- params: z.ZodObject<{
7
- id: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
8
- }, z.core.$strip>;
9
- body: {
10
- content: {
11
- "application/json": {
12
- schema: z.ZodObject<{
13
- title: z.ZodString;
14
- content: z.ZodString;
15
- categoryId: z.ZodNumber;
16
- }, z.core.$strip>;
17
- };
18
- };
2
+ //#region src/api/modules/admin/posts/routes/edit.route.d.ts
3
+ declare const editPostRoute: import("@vitnode/core/api/lib/route").Route<"@vitnode/blog", {
4
+ method: "put";
5
+ path: "/{id}";
6
+ request: {
7
+ params: z.ZodObject<{
8
+ id: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
9
+ }, z.core.$strip>;
10
+ body: {
11
+ content: {
12
+ "application/json": {
13
+ schema: z.ZodObject<{
14
+ title: z.ZodString;
15
+ content: z.ZodString;
16
+ categoryId: z.ZodNumber;
17
+ }, z.core.$strip>;
19
18
  };
19
+ };
20
20
  };
21
- responses: {
22
- 200: {
23
- content: {
24
- "application/json": {
25
- schema: z.ZodObject<{
26
- id: z.ZodNumber;
27
- title: z.ZodString;
28
- titleSeo: z.ZodString;
29
- content: z.ZodString;
30
- categoryId: z.ZodNumber;
31
- createdAt: z.ZodDate;
32
- updatedAt: z.ZodDate;
33
- }, z.core.$strip>;
34
- };
35
- };
36
- description: string;
37
- };
38
- 400: {
39
- description: string;
40
- };
41
- 404: {
42
- description: string;
21
+ };
22
+ responses: {
23
+ 200: {
24
+ content: {
25
+ "application/json": {
26
+ schema: z.ZodObject<{
27
+ id: z.ZodNumber;
28
+ title: z.ZodString;
29
+ titleSeo: z.ZodString;
30
+ content: z.ZodString;
31
+ categoryId: z.ZodNumber;
32
+ createdAt: z.ZodDate;
33
+ updatedAt: z.ZodDate;
34
+ }, z.core.$strip>;
43
35
  };
36
+ };
37
+ description: string;
38
+ };
39
+ 400: {
40
+ description: string;
41
+ };
42
+ 404: {
43
+ description: string;
44
44
  };
45
+ };
45
46
  } & {
46
- path: string;
47
+ path: string;
47
48
  }>;
49
+ //#endregion
50
+ export { editPostRoute };
48
51
  //# sourceMappingURL=edit.route.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"edit.route.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/modules/admin/posts/routes/edit.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAsBtC,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+FxB,CAAC"}
1
+ {"version":3,"file":"edit.route.d.ts","names":[],"sources":["../../../../../../../src/api/modules/admin/posts/routes/edit.route.ts"],"mappings":";;cAsBa,qDAAa"}
@@ -1 +1,2 @@
1
- import{z}from"@hono/zod-openapi";import{buildRoute}from"@vitnode/core/api/lib/route";import{removeSpecialCharacters}from"@vitnode/core/lib/special-characters";import{eq}from"drizzle-orm";import{HTTPException}from"hono/http-exception";import{CONFIG_PLUGIN}from"../../../../../const.js";import{blog_categories}from"../../../../../database/categories.js";import{blog_posts}from"../../../../../database/posts.js";import{zodCreatePostSchema}from"./create.route.js";const zodPostResponseSchema=z.object({id:z.number(),title:z.string(),titleSeo:z.string(),content:z.string(),categoryId:z.number(),createdAt:z.date(),updatedAt:z.date()});export const editPostRoute=buildRoute({pluginId:CONFIG_PLUGIN.pluginId,adminStaffPermission:{module:"posts",permission:"can_edit"},route:{method:"put",path:"/{id}",request:{params:z.object({id:z.string().transform(Number)}),body:{content:{"application/json":{schema:zodCreatePostSchema}}}},responses:{200:{content:{"application/json":{schema:zodPostResponseSchema}},description:"Post updated successfully"},400:{description:"Bad request - Invalid input data"},404:{description:"Post or category not found"}}},handler:async c=>{const{id}=c.req.valid("param");const{title,content,categoryId}=c.req.valid("json");const titleSeo=removeSpecialCharacters(title);const[existingPost]=await c.get("db").select({titleSeo:blog_posts.titleSeo}).from(blog_posts).where(eq(blog_posts.id,id)).limit(1);if(!existingPost){throw new HTTPException(404,{message:"Post not found."})}const[category]=await c.get("db").select({id:blog_categories.id}).from(blog_categories).where(eq(blog_categories.id,categoryId)).limit(1);if(!category){throw new HTTPException(404,{message:"Category not found."})}const[titleSEODuplicate]=await c.get("db").select({titleSeo:blog_posts.titleSeo}).from(blog_posts).where(eq(blog_posts.titleSeo,titleSeo)).limit(1);if(titleSEODuplicate?.titleSeo===titleSeo&&titleSEODuplicate.titleSeo!==existingPost.titleSeo){throw new HTTPException(400,{message:"Post with this title already exists."})}const[post]=await c.get("db").update(blog_posts).set({title,titleSeo,content,categoryId}).where(eq(blog_posts.id,id)).returning();return c.json(post)}});
1
+ import{CONFIG_PLUGIN as e}from"../../../../../const.js";import{blog_categories as t}from"../../../../../database/categories.js";import{blog_posts as n}from"../../../../../database/posts.js";import{zodCreatePostSchema as r}from"./create.route.js";import{z as i}from"@hono/zod-openapi";import{buildRoute as a}from"@vitnode/core/api/lib/route";import{removeSpecialCharacters as o}from"@vitnode/core/lib/special-characters";import{eq as s}from"drizzle-orm";import{HTTPException as c}from"hono/http-exception";const l=i.object({id:i.number(),title:i.string(),titleSeo:i.string(),content:i.string(),categoryId:i.number(),createdAt:i.date(),updatedAt:i.date()}),u=a({pluginId:e.pluginId,adminStaffPermission:{module:`posts`,permission:`can_edit`},route:{method:`put`,path:`/{id}`,request:{params:i.object({id:i.string().transform(Number)}),body:{content:{"application/json":{schema:r}}}},responses:{200:{content:{"application/json":{schema:l}},description:`Post updated successfully`},400:{description:`Bad request - Invalid input data`},404:{description:`Post or category not found`}}},handler:async e=>{let{id:r}=e.req.valid(`param`),{title:i,content:a,categoryId:l}=e.req.valid(`json`),u=o(i),[d]=await e.get(`db`).select({titleSeo:n.titleSeo}).from(n).where(s(n.id,r)).limit(1);if(!d)throw new c(404,{message:`Post not found.`});let[f]=await e.get(`db`).select({id:t.id}).from(t).where(s(t.id,l)).limit(1);if(!f)throw new c(404,{message:`Category not found.`});let[p]=await e.get(`db`).select({titleSeo:n.titleSeo}).from(n).where(s(n.titleSeo,u)).limit(1);if(p?.titleSeo===u&&p.titleSeo!==d.titleSeo)throw new c(400,{message:`Post with this title already exists.`});let[m]=await e.get(`db`).update(n).set({title:i,titleSeo:u,content:a,categoryId:l}).where(s(n.id,r)).returning();return e.json(m)}});export{u as editPostRoute};
2
+ //# sourceMappingURL=edit.route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit.route.js","names":[],"sources":["../../../../../../../src/api/modules/admin/posts/routes/edit.route.ts"],"sourcesContent":["import { z } from \"@hono/zod-openapi\";\nimport { buildRoute } from \"@vitnode/core/api/lib/route\";\nimport { removeSpecialCharacters } from \"@vitnode/core/lib/special-characters\";\nimport { eq } from \"drizzle-orm\";\nimport { HTTPException } from \"hono/http-exception\";\n\nimport { CONFIG_PLUGIN } from \"@/const\";\nimport { blog_categories } from \"@/database/categories\";\nimport { blog_posts } from \"@/database/posts\";\n\nimport { zodCreatePostSchema } from \"./create.route\";\n\nconst zodPostResponseSchema = z.object({\n id: z.number(),\n title: z.string(),\n titleSeo: z.string(),\n content: z.string(),\n categoryId: z.number(),\n createdAt: z.date(),\n updatedAt: z.date(),\n});\n\nexport const editPostRoute = buildRoute({\n pluginId: CONFIG_PLUGIN.pluginId,\n adminStaffPermission: { module: \"posts\", permission: \"can_edit\" },\n route: {\n method: \"put\",\n path: \"/{id}\",\n request: {\n params: z.object({\n id: z.string().transform(Number),\n }),\n body: {\n content: {\n \"application/json\": {\n schema: zodCreatePostSchema,\n },\n },\n },\n },\n responses: {\n 200: {\n content: {\n \"application/json\": {\n schema: zodPostResponseSchema,\n },\n },\n description: \"Post updated successfully\",\n },\n 400: {\n description: \"Bad request - Invalid input data\",\n },\n 404: {\n description: \"Post or category not found\",\n },\n },\n },\n handler: async c => {\n const { id } = c.req.valid(\"param\");\n const { title, content, categoryId } = c.req.valid(\"json\");\n const titleSeo = removeSpecialCharacters(title);\n\n // Check if post exists\n const [existingPost] = await c\n .get(\"db\")\n .select({ titleSeo: blog_posts.titleSeo })\n .from(blog_posts)\n .where(eq(blog_posts.id, id))\n .limit(1);\n\n if (!existingPost) {\n throw new HTTPException(404, { message: \"Post not found.\" });\n }\n\n // Check if category exists\n const [category] = await c\n .get(\"db\")\n .select({ id: blog_categories.id })\n .from(blog_categories)\n .where(eq(blog_categories.id, categoryId))\n .limit(1);\n\n if (!category) {\n throw new HTTPException(404, { message: \"Category not found.\" });\n }\n\n // Check if title SEO already exists (but not for the current post)\n const [titleSEODuplicate] = await c\n .get(\"db\")\n .select({ titleSeo: blog_posts.titleSeo })\n .from(blog_posts)\n .where(eq(blog_posts.titleSeo, titleSeo))\n .limit(1);\n\n if (\n titleSEODuplicate?.titleSeo === titleSeo &&\n titleSEODuplicate.titleSeo !== existingPost.titleSeo\n ) {\n throw new HTTPException(400, {\n message: \"Post with this title already exists.\",\n });\n }\n\n const [post] = await c\n .get(\"db\")\n .update(blog_posts)\n .set({\n title,\n titleSeo,\n content,\n categoryId,\n })\n .where(eq(blog_posts.id, id))\n .returning();\n\n return c.json(post);\n },\n});\n"],"mappings":"yfAYA,MAAM,EAAwB,EAAE,OAAO,CACrC,GAAI,EAAE,OAAO,EACb,MAAO,EAAE,OAAO,EAChB,SAAU,EAAE,OAAO,EACnB,QAAS,EAAE,OAAO,EAClB,WAAY,EAAE,OAAO,EACrB,UAAW,EAAE,KAAK,EAClB,UAAW,EAAE,KAAK,CACpB,CAAC,EAEY,EAAgB,EAAW,CACtC,SAAU,EAAc,SACxB,qBAAsB,CAAE,OAAQ,QAAS,WAAY,UAAW,EAChE,MAAO,CACL,OAAQ,MACR,KAAM,QACN,QAAS,CACP,OAAQ,EAAE,OAAO,CACf,GAAI,EAAE,OAAO,CAAC,CAAC,UAAU,MAAM,CACjC,CAAC,EACD,KAAM,CACJ,QAAS,CACP,mBAAoB,CAClB,OAAQ,CACV,CACF,CACF,CACF,EACA,UAAW,CACT,IAAK,CACH,QAAS,CACP,mBAAoB,CAClB,OAAQ,CACV,CACF,EACA,YAAa,2BACf,EACA,IAAK,CACH,YAAa,kCACf,EACA,IAAK,CACH,YAAa,4BACf,CACF,CACF,EACA,QAAS,KAAM,IAAK,CAClB,GAAM,CAAE,MAAO,EAAE,IAAI,MAAM,OAAO,EAC5B,CAAE,QAAO,UAAS,cAAe,EAAE,IAAI,MAAM,MAAM,EACnD,EAAW,EAAwB,CAAK,EAGxC,CAAC,GAAgB,MAAM,EAC1B,IAAI,IAAI,CAAC,CACT,OAAO,CAAE,SAAU,EAAW,QAAS,CAAC,CAAC,CACzC,KAAK,CAAU,CAAC,CAChB,MAAM,EAAG,EAAW,GAAI,CAAE,CAAC,CAAC,CAC5B,MAAM,CAAC,EAEV,GAAI,CAAC,EACH,MAAM,IAAI,EAAc,IAAK,CAAE,QAAS,iBAAkB,CAAC,EAI7D,GAAM,CAAC,GAAY,MAAM,EACtB,IAAI,IAAI,CAAC,CACT,OAAO,CAAE,GAAI,EAAgB,EAAG,CAAC,CAAC,CAClC,KAAK,CAAe,CAAC,CACrB,MAAM,EAAG,EAAgB,GAAI,CAAU,CAAC,CAAC,CACzC,MAAM,CAAC,EAEV,GAAI,CAAC,EACH,MAAM,IAAI,EAAc,IAAK,CAAE,QAAS,qBAAsB,CAAC,EAIjE,GAAM,CAAC,GAAqB,MAAM,EAC/B,IAAI,IAAI,CAAC,CACT,OAAO,CAAE,SAAU,EAAW,QAAS,CAAC,CAAC,CACzC,KAAK,CAAU,CAAC,CAChB,MAAM,EAAG,EAAW,SAAU,CAAQ,CAAC,CAAC,CACxC,MAAM,CAAC,EAEV,GACE,GAAmB,WAAa,GAChC,EAAkB,WAAa,EAAa,SAE5C,MAAM,IAAI,EAAc,IAAK,CAC3B,QAAS,sCACX,CAAC,EAGH,GAAM,CAAC,GAAQ,MAAM,EAClB,IAAI,IAAI,CAAC,CACT,OAAO,CAAU,CAAC,CAClB,IAAI,CACH,QACA,WACA,UACA,YACF,CAAC,CAAC,CACD,MAAM,EAAG,EAAW,GAAI,CAAE,CAAC,CAAC,CAC5B,UAAU,EAEb,OAAO,EAAE,KAAK,CAAI,CACpB,CACF,CAAC"}
@@ -1,71 +1,74 @@
1
- export declare const categoriesModule: import("@vitnode/core/api/lib/module").BuildModuleReturn<"@vitnode/blog", "categories", [import("@vitnode/core/api/lib/route").Route<"@vitnode/blog", {
2
- method: "get";
3
- path: "/";
4
- request: {
5
- query: import("zod").ZodObject<{
6
- cursor: import("zod").ZodOptional<import("zod").ZodString>;
7
- first: import("zod").ZodOptional<import("zod").ZodString>;
8
- last: import("zod").ZodOptional<import("zod").ZodString>;
9
- order: import("zod").ZodOptional<import("zod").ZodEnum<{
10
- asc: "asc";
11
- desc: "desc";
12
- }>>;
13
- orderBy: import("zod").ZodOptional<import("zod").ZodEnum<{
14
- updatedAt: "updatedAt";
15
- }>>;
16
- search: import("zod").ZodOptional<import("zod").ZodString>;
17
- }, import("zod/v4/core").$strip>;
18
- };
19
- responses: {
20
- 200: {
21
- content: {
22
- "application/json": {
23
- schema: import("zod").ZodObject<{
24
- edges: import("zod").ZodArray<import("zod").ZodObject<{
25
- id: import("zod").ZodNumber;
26
- title: import("zod").ZodString;
27
- createdAt: import("zod").ZodDate;
28
- updatedAt: import("zod").ZodDate;
29
- }, import("zod/v4/core").$strip>>;
30
- pageInfo: import("zod").ZodObject<{
31
- totalCount: import("zod").ZodNumber;
32
- count: import("zod").ZodNumber;
33
- hasNextPage: import("zod").ZodBoolean;
34
- hasPreviousPage: import("zod").ZodBoolean;
35
- startCursor: import("zod").ZodNullable<import("zod").ZodNumber>;
36
- endCursor: import("zod").ZodNullable<import("zod").ZodNumber>;
37
- }, import("zod/v4/core").$strip>;
38
- }, import("zod/v4/core").$strip>;
39
- };
40
- };
41
- description: string;
1
+ //#region src/api/modules/categories/categories.module.d.ts
2
+ declare const categoriesModule: import("@vitnode/core/api/lib/module").BuildModuleReturn<"@vitnode/blog", "categories", [import("@vitnode/core/api/lib/route").Route<"@vitnode/blog", {
3
+ method: "get";
4
+ path: "/";
5
+ request: {
6
+ query: import("zod").ZodObject<{
7
+ cursor: import("zod").ZodOptional<import("zod").ZodString>;
8
+ first: import("zod").ZodOptional<import("zod").ZodString>;
9
+ last: import("zod").ZodOptional<import("zod").ZodString>;
10
+ order: import("zod").ZodOptional<import("zod").ZodEnum<{
11
+ asc: "asc";
12
+ desc: "desc";
13
+ }>>;
14
+ orderBy: import("zod").ZodOptional<import("zod").ZodEnum<{
15
+ updatedAt: "updatedAt";
16
+ }>>;
17
+ search: import("zod").ZodOptional<import("zod").ZodString>;
18
+ }, import("zod/v4/core").$strip>;
19
+ };
20
+ responses: {
21
+ 200: {
22
+ content: {
23
+ "application/json": {
24
+ schema: import("zod").ZodObject<{
25
+ edges: import("zod").ZodArray<import("zod").ZodObject<{
26
+ id: import("zod").ZodNumber;
27
+ title: import("zod").ZodString;
28
+ createdAt: import("zod").ZodDate;
29
+ updatedAt: import("zod").ZodDate;
30
+ }, import("zod/v4/core").$strip>>;
31
+ pageInfo: import("zod").ZodObject<{
32
+ totalCount: import("zod").ZodNumber;
33
+ count: import("zod").ZodNumber;
34
+ hasNextPage: import("zod").ZodBoolean;
35
+ hasPreviousPage: import("zod").ZodBoolean;
36
+ startCursor: import("zod").ZodNullable<import("zod").ZodNumber>;
37
+ endCursor: import("zod").ZodNullable<import("zod").ZodNumber>;
38
+ }, import("zod/v4/core").$strip>;
39
+ }, import("zod/v4/core").$strip>;
42
40
  };
41
+ };
42
+ description: string;
43
43
  };
44
+ };
44
45
  } & {
45
- path: string;
46
+ path: string;
46
47
  }>, import("@vitnode/core/api/lib/route").Route<"@vitnode/blog", {
47
- method: "post";
48
- description: string;
49
- path: "/test";
50
- responses: {
51
- 200: {
52
- content: {
53
- "text/plain": {
54
- schema: import("zod").ZodString;
55
- };
56
- };
57
- description: string;
48
+ method: "post";
49
+ description: string;
50
+ path: "/test";
51
+ responses: {
52
+ 200: {
53
+ content: {
54
+ "text/plain": {
55
+ schema: import("zod").ZodString;
58
56
  };
59
- 201: {
60
- content: {
61
- "text/plain": {
62
- schema: import("zod").ZodString;
63
- };
64
- };
65
- description: string;
57
+ };
58
+ description: string;
59
+ };
60
+ 201: {
61
+ content: {
62
+ "text/plain": {
63
+ schema: import("zod").ZodString;
66
64
  };
65
+ };
66
+ description: string;
67
67
  };
68
+ };
68
69
  } & {
69
- path: string;
70
+ path: string;
70
71
  }>], import("@vitnode/core/api/lib/module").BaseBuildModuleReturn<"@vitnode/blog", string, import("@vitnode/core/api/lib/route").Route<"@vitnode/blog", import("@hono/zod-openapi").RouteConfig>[]>[]>;
72
+ //#endregion
73
+ export { categoriesModule };
71
74
  //# sourceMappingURL=categories.module.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"categories.module.d.ts","sourceRoot":"","sources":["../../../../../src/api/modules/categories/categories.module.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sMAI3B,CAAC"}
1
+ {"version":3,"file":"categories.module.d.ts","names":[],"sources":["../../../../../src/api/modules/categories/categories.module.ts"],"mappings":";cAOa,yDAAgB,wFAAA"}
@@ -1 +1,2 @@
1
- import{buildModule}from"@vitnode/core/api/lib/module";import{CONFIG_PLUGIN}from"../../../const.js";import{categoriesRoute}from"./routes/get.route.js";import{testRoute}from"./test.route.js";export const categoriesModule=buildModule({pluginId:CONFIG_PLUGIN.pluginId,name:"categories",routes:[categoriesRoute,testRoute]});
1
+ import{CONFIG_PLUGIN as e}from"../../../const.js";import{categoriesRoute as t}from"./routes/get.route.js";import{testRoute as n}from"./test.route.js";import{buildModule as r}from"@vitnode/core/api/lib/module";const i=r({pluginId:e.pluginId,name:`categories`,routes:[t,n]});export{i as categoriesModule};
2
+ //# sourceMappingURL=categories.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"categories.module.js","names":[],"sources":["../../../../../src/api/modules/categories/categories.module.ts"],"sourcesContent":["import { buildModule } from \"@vitnode/core/api/lib/module\";\n\nimport { CONFIG_PLUGIN } from \"@/const\";\n\nimport { categoriesRoute } from \"./routes/get.route\";\nimport { testRoute } from \"./test.route\";\n\nexport const categoriesModule = buildModule({\n pluginId: CONFIG_PLUGIN.pluginId,\n name: \"categories\",\n routes: [categoriesRoute, testRoute],\n});\n"],"mappings":"iNAOA,MAAa,EAAmB,EAAY,CAC1C,SAAU,EAAc,SACxB,KAAM,aACN,OAAQ,CAAC,EAAiB,CAAS,CACrC,CAAC"}
@@ -1,48 +1,51 @@
1
1
  import { z } from "@hono/zod-openapi";
2
- export declare const categoriesRoute: import("@vitnode/core/api/lib/route").Route<"@vitnode/blog", {
3
- method: "get";
4
- path: "/";
5
- request: {
6
- query: z.ZodObject<{
7
- cursor: z.ZodOptional<z.ZodString>;
8
- first: z.ZodOptional<z.ZodString>;
9
- last: z.ZodOptional<z.ZodString>;
10
- order: z.ZodOptional<z.ZodEnum<{
11
- asc: "asc";
12
- desc: "desc";
13
- }>>;
14
- orderBy: z.ZodOptional<z.ZodEnum<{
15
- updatedAt: "updatedAt";
16
- }>>;
17
- search: z.ZodOptional<z.ZodString>;
18
- }, z.core.$strip>;
19
- };
20
- responses: {
21
- 200: {
22
- content: {
23
- "application/json": {
24
- schema: z.ZodObject<{
25
- edges: z.ZodArray<z.ZodObject<{
26
- id: z.ZodNumber;
27
- title: z.ZodString;
28
- createdAt: z.ZodDate;
29
- updatedAt: z.ZodDate;
30
- }, z.core.$strip>>;
31
- pageInfo: z.ZodObject<{
32
- totalCount: z.ZodNumber;
33
- count: z.ZodNumber;
34
- hasNextPage: z.ZodBoolean;
35
- hasPreviousPage: z.ZodBoolean;
36
- startCursor: z.ZodNullable<z.ZodNumber>;
37
- endCursor: z.ZodNullable<z.ZodNumber>;
38
- }, z.core.$strip>;
39
- }, z.core.$strip>;
40
- };
41
- };
42
- description: string;
2
+ //#region src/api/modules/categories/routes/get.route.d.ts
3
+ declare const categoriesRoute: import("@vitnode/core/api/lib/route").Route<"@vitnode/blog", {
4
+ method: "get";
5
+ path: "/";
6
+ request: {
7
+ query: z.ZodObject<{
8
+ cursor: z.ZodOptional<z.ZodString>;
9
+ first: z.ZodOptional<z.ZodString>;
10
+ last: z.ZodOptional<z.ZodString>;
11
+ order: z.ZodOptional<z.ZodEnum<{
12
+ asc: "asc";
13
+ desc: "desc";
14
+ }>>;
15
+ orderBy: z.ZodOptional<z.ZodEnum<{
16
+ updatedAt: "updatedAt";
17
+ }>>;
18
+ search: z.ZodOptional<z.ZodString>;
19
+ }, z.core.$strip>;
20
+ };
21
+ responses: {
22
+ 200: {
23
+ content: {
24
+ "application/json": {
25
+ schema: z.ZodObject<{
26
+ edges: z.ZodArray<z.ZodObject<{
27
+ id: z.ZodNumber;
28
+ title: z.ZodString;
29
+ createdAt: z.ZodDate;
30
+ updatedAt: z.ZodDate;
31
+ }, z.core.$strip>>;
32
+ pageInfo: z.ZodObject<{
33
+ totalCount: z.ZodNumber;
34
+ count: z.ZodNumber;
35
+ hasNextPage: z.ZodBoolean;
36
+ hasPreviousPage: z.ZodBoolean;
37
+ startCursor: z.ZodNullable<z.ZodNumber>;
38
+ endCursor: z.ZodNullable<z.ZodNumber>;
39
+ }, z.core.$strip>;
40
+ }, z.core.$strip>;
43
41
  };
42
+ };
43
+ description: string;
44
44
  };
45
+ };
45
46
  } & {
46
- path: string;
47
+ path: string;
47
48
  }>;
49
+ //#endregion
50
+ export { categoriesRoute };
48
51
  //# sourceMappingURL=get.route.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get.route.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/categories/routes/get.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAmBtC,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsE1B,CAAC"}
1
+ {"version":3,"file":"get.route.d.ts","names":[],"sources":["../../../../../../src/api/modules/categories/routes/get.route.ts"],"mappings":";;cAmBa,uDAAe"}
@@ -1 +1,2 @@
1
- import{z}from"@hono/zod-openapi";import{buildRoute}from"@vitnode/core/api/lib/route";import{withPagination,zodPaginationPageInfo,zodPaginationQuery}from"@vitnode/core/api/lib/with-pagination";import{and,ilike}from"drizzle-orm";import{CONFIG_PLUGIN}from"../../../../const.js";import{blog_categories}from"../../../../database/categories.js";const zodCategorySchema=z.object({id:z.number(),title:z.string(),createdAt:z.date(),updatedAt:z.date()});export const categoriesRoute=buildRoute({pluginId:CONFIG_PLUGIN.pluginId,route:{method:"get",path:"/",request:{query:zodPaginationQuery.extend({order:z.enum(["asc","desc"]).optional(),orderBy:z.enum(["updatedAt"]).optional(),search:z.string().optional()})},responses:{200:{content:{"application/json":{schema:z.object({edges:z.array(zodCategorySchema),pageInfo:zodPaginationPageInfo})}},description:"Categories retrieved successfully"}}},handler:async c=>{const query=c.req.valid("query");const data=await withPagination({c,params:{query},primaryCursor:blog_categories.id,query:async({limit,where,orderBy})=>{const searchCondition=query.search?ilike(blog_categories.title,`%${query.search}%`):undefined;let combinedWhere;if(searchCondition){if(where){combinedWhere=and(where,searchCondition)}else{combinedWhere=searchCondition}}else{combinedWhere=where}return await c.get("db").select().from(blog_categories).where(combinedWhere).orderBy(orderBy).limit(limit)},table:blog_categories,orderBy:{column:query.orderBy?blog_categories[query.orderBy]:blog_categories.updatedAt,order:query.order??"desc"}});return c.json(data)}});
1
+ import{CONFIG_PLUGIN as e}from"../../../../const.js";import{blog_categories as t}from"../../../../database/categories.js";import{z as n}from"@hono/zod-openapi";import{buildRoute as r}from"@vitnode/core/api/lib/route";import{and as i,ilike as a}from"drizzle-orm";import{withPagination as o,zodPaginationPageInfo as s,zodPaginationQuery as c}from"@vitnode/core/api/lib/with-pagination";const l=n.object({id:n.number(),title:n.string(),createdAt:n.date(),updatedAt:n.date()}),u=r({pluginId:e.pluginId,route:{method:`get`,path:`/`,request:{query:c.extend({order:n.enum([`asc`,`desc`]).optional(),orderBy:n.enum([`updatedAt`]).optional(),search:n.string().optional()})},responses:{200:{content:{"application/json":{schema:n.object({edges:n.array(l),pageInfo:s})}},description:`Categories retrieved successfully`}}},handler:async e=>{let n=e.req.valid(`query`),r=await o({c:e,params:{query:n},primaryCursor:t.id,query:async({limit:r,where:o,orderBy:s})=>{let c=n.search?a(t.title,`%${n.search}%`):void 0,l;return l=c?o?i(o,c):c:o,await e.get(`db`).select().from(t).where(l).orderBy(s).limit(r)},table:t,orderBy:{column:n.orderBy?t[n.orderBy]:t.updatedAt,order:n.order??`desc`}});return e.json(r)}});export{u as categoriesRoute};
2
+ //# sourceMappingURL=get.route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.route.js","names":[],"sources":["../../../../../../src/api/modules/categories/routes/get.route.ts"],"sourcesContent":["import { z } from \"@hono/zod-openapi\";\nimport { buildRoute } from \"@vitnode/core/api/lib/route\";\nimport {\n withPagination,\n zodPaginationPageInfo,\n zodPaginationQuery,\n} from \"@vitnode/core/api/lib/with-pagination\";\nimport { and, ilike, type SQL } from \"drizzle-orm\";\n\nimport { CONFIG_PLUGIN } from \"@/const\";\nimport { blog_categories } from \"@/database/categories\";\n\nconst zodCategorySchema = z.object({\n id: z.number(),\n title: z.string(),\n createdAt: z.date(),\n updatedAt: z.date(),\n});\n\nexport const categoriesRoute = buildRoute({\n pluginId: CONFIG_PLUGIN.pluginId,\n route: {\n method: \"get\",\n path: \"/\",\n request: {\n query: zodPaginationQuery.extend({\n order: z.enum([\"asc\", \"desc\"]).optional(),\n orderBy: z.enum([\"updatedAt\"]).optional(),\n search: z.string().optional(),\n }),\n },\n responses: {\n 200: {\n content: {\n \"application/json\": {\n schema: z.object({\n edges: z.array(zodCategorySchema),\n pageInfo: zodPaginationPageInfo,\n }),\n },\n },\n description: \"Categories retrieved successfully\",\n },\n },\n },\n handler: async c => {\n const query = c.req.valid(\"query\");\n\n const data = await withPagination({\n c,\n params: {\n query,\n },\n primaryCursor: blog_categories.id,\n query: async ({ limit, where, orderBy }) => {\n const searchCondition = query.search\n ? ilike(blog_categories.title, `%${query.search}%`)\n : undefined;\n\n let combinedWhere: SQL | undefined;\n if (searchCondition) {\n if (where) {\n combinedWhere = and(where, searchCondition);\n } else {\n combinedWhere = searchCondition;\n }\n } else {\n combinedWhere = where;\n }\n\n return await c\n .get(\"db\")\n .select()\n .from(blog_categories)\n .where(combinedWhere)\n .orderBy(orderBy)\n .limit(limit);\n },\n table: blog_categories,\n orderBy: {\n column: query.orderBy\n ? blog_categories[query.orderBy]\n : blog_categories.updatedAt,\n order: query.order ?? \"desc\",\n },\n });\n\n return c.json(data);\n },\n});\n"],"mappings":"gYAYA,MAAM,EAAoB,EAAE,OAAO,CACjC,GAAI,EAAE,OAAO,EACb,MAAO,EAAE,OAAO,EAChB,UAAW,EAAE,KAAK,EAClB,UAAW,EAAE,KAAK,CACpB,CAAC,EAEY,EAAkB,EAAW,CACxC,SAAU,EAAc,SACxB,MAAO,CACL,OAAQ,MACR,KAAM,IACN,QAAS,CACP,MAAO,EAAmB,OAAO,CAC/B,MAAO,EAAE,KAAK,CAAC,MAAO,MAAM,CAAC,CAAC,CAAC,SAAS,EACxC,QAAS,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EACxC,OAAQ,EAAE,OAAO,CAAC,CAAC,SAAS,CAC9B,CAAC,CACH,EACA,UAAW,CACT,IAAK,CACH,QAAS,CACP,mBAAoB,CAClB,OAAQ,EAAE,OAAO,CACf,MAAO,EAAE,MAAM,CAAiB,EAChC,SAAU,CACZ,CAAC,CACH,CACF,EACA,YAAa,mCACf,CACF,CACF,EACA,QAAS,KAAM,IAAK,CAClB,IAAM,EAAQ,EAAE,IAAI,MAAM,OAAO,EAE3B,EAAO,MAAM,EAAe,CAChC,IACA,OAAQ,CACN,OACF,EACA,cAAe,EAAgB,GAC/B,MAAO,MAAO,CAAE,QAAO,QAAO,aAAc,CAC1C,IAAM,EAAkB,EAAM,OAC1B,EAAM,EAAgB,MAAO,IAAI,EAAM,OAAO,EAAE,EAChD,IAAA,GAEA,EAWJ,MAVA,CAOE,EAPE,EACE,EACc,EAAI,EAAO,CAAe,EAE1B,EAGF,EAGX,MAAM,EACV,IAAI,IAAI,CAAC,CACT,OAAO,CAAC,CACR,KAAK,CAAe,CAAC,CACrB,MAAM,CAAa,CAAC,CACpB,QAAQ,CAAO,CAAC,CAChB,MAAM,CAAK,CAChB,EACA,MAAO,EACP,QAAS,CACP,OAAQ,EAAM,QACV,EAAgB,EAAM,SACtB,EAAgB,UACpB,MAAO,EAAM,OAAS,MACxB,CACF,CAAC,EAED,OAAO,EAAE,KAAK,CAAI,CACpB,CACF,CAAC"}
@@ -1,27 +1,30 @@
1
1
  import { z } from "zod";
2
- export declare const testRoute: import("@vitnode/core/api/lib/route").Route<"@vitnode/blog", {
3
- method: "post";
4
- description: string;
5
- path: "/test";
6
- responses: {
7
- 200: {
8
- content: {
9
- "text/plain": {
10
- schema: z.ZodString;
11
- };
12
- };
13
- description: string;
2
+ //#region src/api/modules/categories/test.route.d.ts
3
+ declare const testRoute: import("@vitnode/core/api/lib/route").Route<"@vitnode/blog", {
4
+ method: "post";
5
+ description: string;
6
+ path: "/test";
7
+ responses: {
8
+ 200: {
9
+ content: {
10
+ "text/plain": {
11
+ schema: z.ZodString;
14
12
  };
15
- 201: {
16
- content: {
17
- "text/plain": {
18
- schema: z.ZodString;
19
- };
20
- };
21
- description: string;
13
+ };
14
+ description: string;
15
+ };
16
+ 201: {
17
+ content: {
18
+ "text/plain": {
19
+ schema: z.ZodString;
22
20
  };
21
+ };
22
+ description: string;
23
23
  };
24
+ };
24
25
  } & {
25
- path: string;
26
+ path: string;
26
27
  }>;
28
+ //#endregion
29
+ export { testRoute };
27
30
  //# sourceMappingURL=test.route.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"test.route.d.ts","sourceRoot":"","sources":["../../../../../src/api/modules/categories/test.route.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;EA2CpB,CAAC"}
1
+ {"version":3,"file":"test.route.d.ts","names":[],"sources":["../../../../../src/api/modules/categories/test.route.ts"],"mappings":";;cAOa,iDAAS;;;;;;;;kBAAT,EAAA;;;;;;;;kBAAA,EAAA"}
@@ -1 +1,2 @@
1
- import{buildRoute}from"@vitnode/core/api/lib/route";import{UserModel}from"@vitnode/core/api/models/user";import{z}from"zod";import{CONFIG_PLUGIN}from"../../../const.js";import TestTemplateEmail from"../../../emails/test-template.js";export const testRoute=buildRoute({pluginId:CONFIG_PLUGIN.pluginId,route:{method:"post",description:"Test route",path:"/test",responses:{200:{content:{"text/plain":{schema:z.string()}},description:"User"},201:{content:{"text/plain":{schema:z.string()}},description:"User"}}},handler:async c=>{const user=await new UserModel().getUserById({id:2,c});if(!user)throw new Error("User not found");await c.get("email").send({subject:"Test Email",content:TestTemplateEmail,user});await c.get("log").warn("This is a test warn log");return c.text("test")}});
1
+ import{CONFIG_PLUGIN as e}from"../../../const.js";import t from"../../../emails/test-template.js";import{buildRoute as n}from"@vitnode/core/api/lib/route";import{UserModel as r}from"@vitnode/core/api/models/user";import{z as i}from"zod";const a=n({pluginId:e.pluginId,route:{method:`post`,description:`Test route`,path:`/test`,responses:{200:{content:{"text/plain":{schema:i.string()}},description:`User`},201:{content:{"text/plain":{schema:i.string()}},description:`User`}}},handler:async e=>{let n=await new r().getUserById({id:2,c:e});if(!n)throw Error(`User not found`);return await e.get(`email`).send({subject:`Test Email`,content:t,user:n}),await e.get(`log`).warn(`This is a test warn log`),e.text(`test`)}});export{a as testRoute};
2
+ //# sourceMappingURL=test.route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.route.js","names":[],"sources":["../../../../../src/api/modules/categories/test.route.ts"],"sourcesContent":["import { buildRoute } from \"@vitnode/core/api/lib/route\";\nimport { UserModel } from \"@vitnode/core/api/models/user\";\nimport { z } from \"zod\";\n\nimport { CONFIG_PLUGIN } from \"@/const\";\nimport TestTemplateEmail from \"@/emails/test-template\";\n\nexport const testRoute = buildRoute({\n pluginId: CONFIG_PLUGIN.pluginId,\n route: {\n method: \"post\",\n description: \"Test route\",\n path: \"/test\",\n responses: {\n 200: {\n content: {\n \"text/plain\": {\n schema: z.string(),\n },\n },\n description: \"User\",\n },\n 201: {\n content: {\n \"text/plain\": {\n schema: z.string(),\n },\n },\n description: \"User\",\n },\n },\n },\n handler: async c => {\n const user = await new UserModel().getUserById({\n id: 2,\n c,\n });\n\n if (!user) throw new Error(\"User not found\");\n\n await c.get(\"email\").send({\n subject: \"Test Email\",\n content: TestTemplateEmail,\n user,\n });\n\n await c.get(\"log\").warn(\"This is a test warn log\");\n\n return c.text(\"test\");\n },\n});\n"],"mappings":"6OAOA,MAAa,EAAY,EAAW,CAClC,SAAU,EAAc,SACxB,MAAO,CACL,OAAQ,OACR,YAAa,aACb,KAAM,QACN,UAAW,CACT,IAAK,CACH,QAAS,CACP,aAAc,CACZ,OAAQ,EAAE,OAAO,CACnB,CACF,EACA,YAAa,MACf,EACA,IAAK,CACH,QAAS,CACP,aAAc,CACZ,OAAQ,EAAE,OAAO,CACnB,CACF,EACA,YAAa,MACf,CACF,CACF,EACA,QAAS,KAAM,IAAK,CAClB,IAAM,EAAO,MAAM,IAAI,EAAU,CAAC,CAAC,YAAY,CAC7C,GAAI,EACJ,GACF,CAAC,EAED,GAAI,CAAC,EAAM,MAAU,MAAM,gBAAgB,EAU3C,OARA,MAAM,EAAE,IAAI,OAAO,CAAC,CAAC,KAAK,CACxB,QAAS,aACT,QAAS,EACT,MACF,CAAC,EAED,MAAM,EAAE,IAAI,KAAK,CAAC,CAAC,KAAK,yBAAyB,EAE1C,EAAE,KAAK,MAAM,CACtB,CACF,CAAC"}