@vitnode/blog 1.2.0-canary.74 → 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.
- package/dist/src/api/modules/admin/admin.module.d.ts +180 -177
- package/dist/src/api/modules/admin/admin.module.d.ts.map +1 -1
- package/dist/src/api/modules/admin/admin.module.js +2 -1
- package/dist/src/api/modules/admin/admin.module.js.map +1 -0
- package/dist/src/api/modules/admin/categories/categories.admin.module.d.ts +80 -77
- package/dist/src/api/modules/admin/categories/categories.admin.module.d.ts.map +1 -1
- package/dist/src/api/modules/admin/categories/categories.admin.module.js +2 -1
- package/dist/src/api/modules/admin/categories/categories.admin.module.js.map +1 -0
- package/dist/src/api/modules/admin/categories/routes/create.route.d.ts +34 -31
- package/dist/src/api/modules/admin/categories/routes/create.route.d.ts.map +1 -1
- package/dist/src/api/modules/admin/categories/routes/create.route.js +2 -1
- package/dist/src/api/modules/admin/categories/routes/create.route.js.map +1 -0
- package/dist/src/api/modules/admin/categories/routes/delete.route.d.ts +18 -15
- package/dist/src/api/modules/admin/categories/routes/delete.route.d.ts.map +1 -1
- package/dist/src/api/modules/admin/categories/routes/delete.route.js +2 -1
- package/dist/src/api/modules/admin/categories/routes/delete.route.js.map +1 -0
- package/dist/src/api/modules/admin/categories/routes/edit.route.d.ts +38 -35
- package/dist/src/api/modules/admin/categories/routes/edit.route.d.ts.map +1 -1
- package/dist/src/api/modules/admin/categories/routes/edit.route.js +2 -1
- package/dist/src/api/modules/admin/categories/routes/edit.route.js.map +1 -0
- package/dist/src/api/modules/admin/posts/posts.admin.module.d.ts +93 -90
- package/dist/src/api/modules/admin/posts/posts.admin.module.d.ts.map +1 -1
- package/dist/src/api/modules/admin/posts/posts.admin.module.js +2 -1
- package/dist/src/api/modules/admin/posts/posts.admin.module.js.map +1 -0
- package/dist/src/api/modules/admin/posts/routes/create.route.d.ts +44 -41
- package/dist/src/api/modules/admin/posts/routes/create.route.d.ts.map +1 -1
- package/dist/src/api/modules/admin/posts/routes/create.route.js +2 -1
- package/dist/src/api/modules/admin/posts/routes/create.route.js.map +1 -0
- package/dist/src/api/modules/admin/posts/routes/delete.route.d.ts +18 -15
- package/dist/src/api/modules/admin/posts/routes/delete.route.d.ts.map +1 -1
- package/dist/src/api/modules/admin/posts/routes/delete.route.js +2 -1
- package/dist/src/api/modules/admin/posts/routes/delete.route.js.map +1 -0
- package/dist/src/api/modules/admin/posts/routes/edit.route.d.ts +43 -40
- package/dist/src/api/modules/admin/posts/routes/edit.route.d.ts.map +1 -1
- package/dist/src/api/modules/admin/posts/routes/edit.route.js +2 -1
- package/dist/src/api/modules/admin/posts/routes/edit.route.js.map +1 -0
- package/dist/src/api/modules/categories/categories.module.d.ts +64 -61
- package/dist/src/api/modules/categories/categories.module.d.ts.map +1 -1
- package/dist/src/api/modules/categories/categories.module.js +2 -1
- package/dist/src/api/modules/categories/categories.module.js.map +1 -0
- package/dist/src/api/modules/categories/routes/get.route.d.ts +45 -42
- package/dist/src/api/modules/categories/routes/get.route.d.ts.map +1 -1
- package/dist/src/api/modules/categories/routes/get.route.js +2 -1
- package/dist/src/api/modules/categories/routes/get.route.js.map +1 -0
- package/dist/src/api/modules/categories/test.route.d.ts +23 -20
- package/dist/src/api/modules/categories/test.route.d.ts.map +1 -1
- package/dist/src/api/modules/categories/test.route.js +2 -1
- package/dist/src/api/modules/categories/test.route.js.map +1 -0
- package/dist/src/api/modules/posts/posts.module.d.ts +54 -51
- package/dist/src/api/modules/posts/posts.module.d.ts.map +1 -1
- package/dist/src/api/modules/posts/posts.module.js +2 -1
- package/dist/src/api/modules/posts/posts.module.js.map +1 -0
- package/dist/src/api/modules/posts/routes/get.route.d.ts +64 -61
- package/dist/src/api/modules/posts/routes/get.route.d.ts.map +1 -1
- package/dist/src/api/modules/posts/routes/get.route.js +2 -1
- package/dist/src/api/modules/posts/routes/get.route.js.map +1 -0
- package/dist/src/config.api.d.ts +4 -1
- package/dist/src/config.api.d.ts.map +1 -1
- package/dist/src/config.api.js +2 -1
- package/dist/src/config.api.js.map +1 -0
- package/dist/src/config.d.ts +4 -1
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +2 -1
- package/dist/src/config.js.map +1 -0
- package/dist/src/const.d.ts +5 -2
- package/dist/src/const.d.ts.map +1 -1
- package/dist/src/const.js +2 -1
- package/dist/src/const.js.map +1 -0
- package/dist/src/database/categories.d.ts +98 -95
- package/dist/src/database/categories.d.ts.map +1 -1
- package/dist/src/database/categories.js +2 -1
- package/dist/src/database/categories.js.map +1 -0
- package/dist/src/database/index.d.ts +4 -4
- package/dist/src/database/index.js +1 -1
- package/dist/src/database/posts.d.ts +132 -129
- package/dist/src/database/posts.d.ts.map +1 -1
- package/dist/src/database/posts.js +2 -1
- package/dist/src/database/posts.js.map +1 -0
- package/dist/src/database/relations.d.ts +7 -4
- package/dist/src/database/relations.d.ts.map +1 -1
- package/dist/src/database/relations.js +2 -1
- package/dist/src/database/relations.js.map +1 -0
- package/dist/src/emails/test-template.d.ts +20 -18
- package/dist/src/emails/test-template.d.ts.map +1 -1
- package/dist/src/emails/test-template.js +2 -1
- package/dist/src/emails/test-template.js.map +1 -0
- package/dist/src/routes/admin/blog/categories/page.d.ts +7 -5
- package/dist/src/routes/admin/blog/categories/page.d.ts.map +1 -1
- package/dist/src/routes/admin/blog/categories/page.js +2 -1
- package/dist/src/routes/admin/blog/categories/page.js.map +1 -0
- package/dist/src/routes/admin/blog/posts/page.d.ts +7 -5
- package/dist/src/routes/admin/blog/posts/page.d.ts.map +1 -1
- package/dist/src/routes/admin/blog/posts/page.js +2 -1
- package/dist/src/routes/admin/blog/posts/page.js.map +1 -0
- package/dist/src/views/admin/categories/actions/actions.d.ts +4 -1
- package/dist/src/views/admin/categories/actions/actions.d.ts.map +1 -1
- package/dist/src/views/admin/categories/actions/actions.js +2 -1
- package/dist/src/views/admin/categories/actions/actions.js.map +1 -0
- package/dist/src/views/admin/categories/actions/create-edit/create-edit.d.ts +8 -5
- package/dist/src/views/admin/categories/actions/create-edit/create-edit.d.ts.map +1 -1
- package/dist/src/views/admin/categories/actions/create-edit/create-edit.js +2 -1
- package/dist/src/views/admin/categories/actions/create-edit/create-edit.js.map +1 -0
- package/dist/src/views/admin/categories/actions/create-edit/mutation-api.d.ts +10 -7
- package/dist/src/views/admin/categories/actions/create-edit/mutation-api.d.ts.map +1 -1
- package/dist/src/views/admin/categories/actions/create-edit/mutation-api.js +2 -1
- package/dist/src/views/admin/categories/actions/create-edit/mutation-api.js.map +1 -0
- package/dist/src/views/admin/categories/table/actions/delete/delete-action.d.ts +7 -4
- package/dist/src/views/admin/categories/table/actions/delete/delete-action.d.ts.map +1 -1
- package/dist/src/views/admin/categories/table/actions/delete/delete-action.js +2 -1
- package/dist/src/views/admin/categories/table/actions/delete/delete-action.js.map +1 -0
- package/dist/src/views/admin/categories/table/actions/delete/mutation-api.d.ts +5 -2
- package/dist/src/views/admin/categories/table/actions/delete/mutation-api.d.ts.map +1 -1
- package/dist/src/views/admin/categories/table/actions/delete/mutation-api.js +2 -1
- package/dist/src/views/admin/categories/table/actions/delete/mutation-api.js.map +1 -0
- package/dist/src/views/admin/categories/table/actions/edit-action.d.ts +8 -5
- package/dist/src/views/admin/categories/table/actions/edit-action.d.ts.map +1 -1
- package/dist/src/views/admin/categories/table/actions/edit-action.js +2 -1
- package/dist/src/views/admin/categories/table/actions/edit-action.js.map +1 -0
- package/dist/src/views/admin/categories/table/categories-admin-view.d.ts +5 -2
- package/dist/src/views/admin/categories/table/categories-admin-view.d.ts.map +1 -1
- package/dist/src/views/admin/categories/table/categories-admin-view.js +2 -1
- package/dist/src/views/admin/categories/table/categories-admin-view.js.map +1 -0
- package/dist/src/views/admin/posts/actions/actions.d.ts +4 -1
- package/dist/src/views/admin/posts/actions/actions.d.ts.map +1 -1
- package/dist/src/views/admin/posts/actions/actions.js +2 -1
- package/dist/src/views/admin/posts/actions/actions.js.map +1 -0
- package/dist/src/views/admin/posts/actions/create-edit/create-edit.d.ts +8 -5
- package/dist/src/views/admin/posts/actions/create-edit/create-edit.d.ts.map +1 -1
- package/dist/src/views/admin/posts/actions/create-edit/create-edit.js +2 -1
- package/dist/src/views/admin/posts/actions/create-edit/create-edit.js.map +1 -0
- package/dist/src/views/admin/posts/actions/create-edit/mutation-api.d.ts +10 -7
- package/dist/src/views/admin/posts/actions/create-edit/mutation-api.d.ts.map +1 -1
- package/dist/src/views/admin/posts/actions/create-edit/mutation-api.js +2 -1
- package/dist/src/views/admin/posts/actions/create-edit/mutation-api.js.map +1 -0
- package/dist/src/views/admin/posts/table/actions/delete/delete-action.d.ts +7 -4
- package/dist/src/views/admin/posts/table/actions/delete/delete-action.d.ts.map +1 -1
- package/dist/src/views/admin/posts/table/actions/delete/delete-action.js +2 -1
- package/dist/src/views/admin/posts/table/actions/delete/delete-action.js.map +1 -0
- package/dist/src/views/admin/posts/table/actions/delete/mutation-api.d.ts +5 -2
- package/dist/src/views/admin/posts/table/actions/delete/mutation-api.d.ts.map +1 -1
- package/dist/src/views/admin/posts/table/actions/delete/mutation-api.js +2 -1
- package/dist/src/views/admin/posts/table/actions/delete/mutation-api.js.map +1 -0
- package/dist/src/views/admin/posts/table/actions/edit-action.d.ts +8 -5
- package/dist/src/views/admin/posts/table/actions/edit-action.d.ts.map +1 -1
- package/dist/src/views/admin/posts/table/actions/edit-action.js +2 -1
- package/dist/src/views/admin/posts/table/actions/edit-action.js.map +1 -0
- package/dist/src/views/admin/posts/table/posts-admin-view.d.ts +5 -2
- package/dist/src/views/admin/posts/table/posts-admin-view.d.ts.map +1 -1
- package/dist/src/views/admin/posts/table/posts-admin-view.js +2 -1
- package/dist/src/views/admin/posts/table/posts-admin-view.js.map +1 -0
- package/package.json +12 -15
- package/src/locales/en.json +11 -1
- package/src/routes/admin/blog/categories/page.tsx +19 -2
- package/src/routes/admin/blog/posts/page.tsx +19 -2
- package/tsconfig.build.json +5 -0
- 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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
description: string;
|
|
13
|
-
};
|
|
14
|
-
404: {
|
|
15
|
-
description: string;
|
|
16
|
-
};
|
|
15
|
+
404: {
|
|
16
|
+
description: string;
|
|
17
17
|
};
|
|
18
|
+
};
|
|
18
19
|
} & {
|
|
19
|
-
|
|
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","
|
|
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";
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
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","
|
|
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";
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
46
|
+
path: string;
|
|
46
47
|
}>, import("@vitnode/core/api/lib/route").Route<"@vitnode/blog", {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
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","
|
|
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{
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
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","
|
|
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";
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
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","
|
|
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";
|
|
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"}
|