@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
|
@@ -1,40 +1,43 @@
|
|
|
1
1
|
import { z } from "@hono/zod-openapi";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
//#region src/api/modules/admin/categories/routes/create.route.d.ts
|
|
3
|
+
declare const zodCreateCategorySchema: z.ZodObject<{
|
|
4
|
+
title: z.ZodString;
|
|
4
5
|
}, z.core.$strip>;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
};
|
|
6
|
+
declare const createCategoryRoute: import("@vitnode/core/api/lib/route").Route<"@vitnode/blog", {
|
|
7
|
+
method: "post";
|
|
8
|
+
path: "/";
|
|
9
|
+
request: {
|
|
10
|
+
body: {
|
|
11
|
+
content: {
|
|
12
|
+
"application/json": {
|
|
13
|
+
schema: z.ZodObject<{
|
|
14
|
+
title: z.ZodString;
|
|
15
|
+
}, z.core.$strip>;
|
|
17
16
|
};
|
|
17
|
+
};
|
|
18
18
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
description: string;
|
|
32
|
-
};
|
|
33
|
-
400: {
|
|
34
|
-
description: string;
|
|
19
|
+
};
|
|
20
|
+
responses: {
|
|
21
|
+
201: {
|
|
22
|
+
content: {
|
|
23
|
+
"application/json": {
|
|
24
|
+
schema: z.ZodObject<{
|
|
25
|
+
id: z.ZodNumber;
|
|
26
|
+
title: z.ZodString;
|
|
27
|
+
createdAt: z.ZodDate;
|
|
28
|
+
updatedAt: z.ZodDate;
|
|
29
|
+
}, z.core.$strip>;
|
|
35
30
|
};
|
|
31
|
+
};
|
|
32
|
+
description: string;
|
|
33
|
+
};
|
|
34
|
+
400: {
|
|
35
|
+
description: string;
|
|
36
36
|
};
|
|
37
|
+
};
|
|
37
38
|
} & {
|
|
38
|
-
|
|
39
|
+
path: string;
|
|
39
40
|
}>;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { createCategoryRoute, zodCreateCategorySchema };
|
|
40
43
|
//# sourceMappingURL=create.route.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.route.d.ts","
|
|
1
|
+
{"version":3,"file":"create.route.d.ts","names":[],"sources":["../../../../../../../src/api/modules/admin/categories/routes/create.route.ts"],"mappings":";;cAgBa,yBAAuB,EAAA;;;cAIvB,2DAAmB"}
|
|
@@ -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{z as n}from"@hono/zod-openapi";import{buildRoute as r}from"@vitnode/core/api/lib/route";import{removeSpecialCharacters as i}from"@vitnode/core/lib/special-characters";import{eq as a}from"drizzle-orm";import{HTTPException as o}from"hono/http-exception";const s=n.object({id:n.number(),title:n.string(),createdAt:n.date(),updatedAt:n.date()}),c=n.object({title:n.string()}),l=r({pluginId:e.pluginId,adminStaffPermission:{module:`categories`,permission:`can_create`},route:{method:`post`,path:`/`,request:{body:{content:{"application/json":{schema:c}}}},responses:{201:{content:{"application/json":{schema:s}},description:`Category created successfully`},400:{description:`Bad request - Invalid input data`}}},handler:async e=>{let{title:n}=e.req.valid(`json`),r=i(n),[s]=await e.get(`db`).select({titleSeo:t.titleSeo}).from(t).where(a(t.titleSeo,r)).limit(1);if(s?.titleSeo===r)throw new o(400,{message:`Category with this title already exists.`});let[c]=await e.get(`db`).insert(t).values({title:n,titleSeo:i(n)}).returning();return e.json(c,201)}});export{l as createCategoryRoute,c as zodCreateCategorySchema};
|
|
2
|
+
//# sourceMappingURL=create.route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.route.js","names":[],"sources":["../../../../../../../src/api/modules/admin/categories/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\";\n\nconst zodCategoryResponseSchema = z.object({\n id: z.number(),\n title: z.string(),\n createdAt: z.date(),\n updatedAt: z.date(),\n});\n\nexport const zodCreateCategorySchema = z.object({\n title: z.string(),\n});\n\nexport const createCategoryRoute = buildRoute({\n pluginId: CONFIG_PLUGIN.pluginId,\n adminStaffPermission: { module: \"categories\", permission: \"can_create\" },\n route: {\n method: \"post\",\n path: \"/\",\n request: {\n body: {\n content: {\n \"application/json\": {\n schema: zodCreateCategorySchema,\n },\n },\n },\n },\n responses: {\n 201: {\n content: {\n \"application/json\": {\n schema: zodCategoryResponseSchema,\n },\n },\n description: \"Category created successfully\",\n },\n 400: {\n description: \"Bad request - Invalid input data\",\n },\n },\n },\n handler: async c => {\n const { title } = c.req.valid(\"json\");\n const titleSeo = removeSpecialCharacters(title);\n const [titleSEODuplocate] = await c\n .get(\"db\")\n .select({\n titleSeo: blog_categories.titleSeo,\n })\n .from(blog_categories)\n .where(eq(blog_categories.titleSeo, titleSeo))\n .limit(1);\n\n if (titleSEODuplocate?.titleSeo === titleSeo) {\n throw new HTTPException(400, {\n message: \"Category with this title already exists.\",\n });\n }\n\n const [category] = await c\n .get(\"db\")\n .insert(blog_categories)\n .values({\n title,\n titleSeo: removeSpecialCharacters(title),\n })\n .returning();\n\n return c.json(category, 201);\n },\n});\n"],"mappings":"mYASA,MAAM,EAA4B,EAAE,OAAO,CACzC,GAAI,EAAE,OAAO,EACb,MAAO,EAAE,OAAO,EAChB,UAAW,EAAE,KAAK,EAClB,UAAW,EAAE,KAAK,CACpB,CAAC,EAEY,EAA0B,EAAE,OAAO,CAC9C,MAAO,EAAE,OAAO,CAClB,CAAC,EAEY,EAAsB,EAAW,CAC5C,SAAU,EAAc,SACxB,qBAAsB,CAAE,OAAQ,aAAc,WAAY,YAAa,EACvE,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,+BACf,EACA,IAAK,CACH,YAAa,kCACf,CACF,CACF,EACA,QAAS,KAAM,IAAK,CAClB,GAAM,CAAE,SAAU,EAAE,IAAI,MAAM,MAAM,EAC9B,EAAW,EAAwB,CAAK,EACxC,CAAC,GAAqB,MAAM,EAC/B,IAAI,IAAI,CAAC,CACT,OAAO,CACN,SAAU,EAAgB,QAC5B,CAAC,CAAC,CACD,KAAK,CAAe,CAAC,CACrB,MAAM,EAAG,EAAgB,SAAU,CAAQ,CAAC,CAAC,CAC7C,MAAM,CAAC,EAEV,GAAI,GAAmB,WAAa,EAClC,MAAM,IAAI,EAAc,IAAK,CAC3B,QAAS,0CACX,CAAC,EAGH,GAAM,CAAC,GAAY,MAAM,EACtB,IAAI,IAAI,CAAC,CACT,OAAO,CAAe,CAAC,CACvB,OAAO,CACN,QACA,SAAU,EAAwB,CAAK,CACzC,CAAC,CAAC,CACD,UAAU,EAEb,OAAO,EAAE,KAAK,EAAU,GAAG,CAC7B,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/categories/routes/delete.route.d.ts
|
|
3
|
+
declare const deleteCategoryRoute: 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 { deleteCategoryRoute };
|
|
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/categories/routes/delete.route.ts"],"mappings":";;cAQa,2DAAmB"}
|
|
@@ -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_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{eq as i}from"drizzle-orm";import{HTTPException as a}from"hono/http-exception";const o=r({pluginId:e.pluginId,adminStaffPermission:{module:`categories`,permission:`can_delete`},route:{method:`delete`,path:`/{id}`,request:{params:n.object({id:n.string().transform(Number)})},responses:{204:{description:`Category deleted successfully`},404:{description:`Category 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 deleteCategoryRoute};
|
|
2
|
+
//# sourceMappingURL=delete.route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.route.js","names":[],"sources":["../../../../../../../src/api/modules/admin/categories/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_categories } from \"@/database/categories\";\n\nexport const deleteCategoryRoute = buildRoute({\n pluginId: CONFIG_PLUGIN.pluginId,\n adminStaffPermission: { module: \"categories\", 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: \"Category deleted successfully\",\n },\n 404: {\n description: \"Category 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_categories)\n .where(eq(blog_categories.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":"oTAQA,MAAa,EAAsB,EAAW,CAC5C,SAAU,EAAc,SACxB,qBAAsB,CAAE,OAAQ,aAAc,WAAY,YAAa,EACvE,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,+BACf,EACA,IAAK,CACH,YAAa,oBACf,CACF,CACF,EACA,QAAS,KAAM,IAAK,CAClB,GAAM,CAAE,MAAO,EAAE,IAAI,MAAM,OAAO,EAQlC,IAAI,MANiB,EAClB,IAAI,IAAI,CAAC,CACT,OAAO,CAAe,CAAC,CACvB,MAAM,EAAG,EAAgB,GAAI,CAAE,CAAC,CAAC,CACjC,UAAU,EAAA,CAEF,SAAW,EACpB,MAAM,IAAI,EAAc,GAAG,EAG7B,OAAO,EAAE,KAAK,KAAM,GAAG,CACzB,CACF,CAAC"}
|
|
@@ -1,43 +1,46 @@
|
|
|
1
1
|
import { z } from "@hono/zod-openapi";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
2
|
+
//#region src/api/modules/admin/categories/routes/edit.route.d.ts
|
|
3
|
+
declare const editCategoryRoute: 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
|
+
}, z.core.$strip>;
|
|
17
16
|
};
|
|
17
|
+
};
|
|
18
18
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
description: string;
|
|
32
|
-
};
|
|
33
|
-
400: {
|
|
34
|
-
description: string;
|
|
35
|
-
};
|
|
36
|
-
404: {
|
|
37
|
-
description: string;
|
|
19
|
+
};
|
|
20
|
+
responses: {
|
|
21
|
+
200: {
|
|
22
|
+
content: {
|
|
23
|
+
"application/json": {
|
|
24
|
+
schema: z.ZodObject<{
|
|
25
|
+
id: z.ZodNumber;
|
|
26
|
+
title: z.ZodString;
|
|
27
|
+
createdAt: z.ZodDate;
|
|
28
|
+
updatedAt: z.ZodDate;
|
|
29
|
+
}, z.core.$strip>;
|
|
38
30
|
};
|
|
31
|
+
};
|
|
32
|
+
description: string;
|
|
33
|
+
};
|
|
34
|
+
400: {
|
|
35
|
+
description: string;
|
|
36
|
+
};
|
|
37
|
+
404: {
|
|
38
|
+
description: string;
|
|
39
39
|
};
|
|
40
|
+
};
|
|
40
41
|
} & {
|
|
41
|
-
|
|
42
|
+
path: string;
|
|
42
43
|
}>;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { editCategoryRoute };
|
|
43
46
|
//# 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/categories/routes/edit.route.ts"],"mappings":";;cAkBa,yDAAiB"}
|
|
@@ -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{zodCreateCategorySchema as n}from"./create.route.js";import{z as r}from"@hono/zod-openapi";import{buildRoute as i}from"@vitnode/core/api/lib/route";import{removeSpecialCharacters as a}from"@vitnode/core/lib/special-characters";import{eq as o}from"drizzle-orm";import{HTTPException as s}from"hono/http-exception";const c=r.object({id:r.number(),title:r.string(),createdAt:r.date(),updatedAt:r.date()}),l=i({pluginId:e.pluginId,adminStaffPermission:{module:`categories`,permission:`can_edit`},route:{method:`put`,path:`/{id}`,request:{params:r.object({id:r.string().transform(Number)}),body:{content:{"application/json":{schema:n}}}},responses:{200:{content:{"application/json":{schema:c}},description:`Category updated successfully`},400:{description:`Bad request - Invalid input data`},404:{description:`Category not found`}}},handler:async e=>{let{id:n}=e.req.valid(`param`),{title:r}=e.req.valid(`json`),i=a(r),[c]=await e.get(`db`).select({titleSeo:t.titleSeo}).from(t).where(o(t.id,n)).limit(1);if(!c)throw new s(404);let[l]=await e.get(`db`).select({titleSeo:t.titleSeo}).from(t).where(o(t.titleSeo,i)).limit(1);if(l?.titleSeo===i&&l.titleSeo!==c.titleSeo)throw new s(400,{message:`Category with this title already exists.`});let[u]=await e.get(`db`).update(t).set({title:r,titleSeo:a(r)}).where(o(t.id,n)).returning();return e.json(u)}});export{l as editCategoryRoute};
|
|
2
|
+
//# sourceMappingURL=edit.route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit.route.js","names":[],"sources":["../../../../../../../src/api/modules/admin/categories/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\";\n\nimport { zodCreateCategorySchema } from \"./create.route\";\n\nconst zodCategoryResponseSchema = z.object({\n id: z.number(),\n title: z.string(),\n createdAt: z.date(),\n updatedAt: z.date(),\n});\n\nexport const editCategoryRoute = buildRoute({\n pluginId: CONFIG_PLUGIN.pluginId,\n adminStaffPermission: { module: \"categories\", 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: zodCreateCategorySchema,\n },\n },\n },\n },\n responses: {\n 200: {\n content: {\n \"application/json\": {\n schema: zodCategoryResponseSchema,\n },\n },\n description: \"Category updated 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 { id } = c.req.valid(\"param\");\n const { title } = c.req.valid(\"json\");\n const titleSeo = removeSpecialCharacters(title);\n const [editData] = await c\n .get(\"db\")\n .select({\n titleSeo: blog_categories.titleSeo,\n })\n .from(blog_categories)\n .where(eq(blog_categories.id, id))\n .limit(1);\n\n if (!editData) {\n throw new HTTPException(404);\n }\n\n const [titleSEODuplocate] = await c\n .get(\"db\")\n .select({\n titleSeo: blog_categories.titleSeo,\n })\n .from(blog_categories)\n .where(eq(blog_categories.titleSeo, titleSeo))\n .limit(1);\n\n if (\n titleSEODuplocate?.titleSeo === titleSeo &&\n titleSEODuplocate.titleSeo !== editData.titleSeo\n ) {\n throw new HTTPException(400, {\n message: \"Category with this title already exists.\",\n });\n }\n\n const [category] = await c\n .get(\"db\")\n .update(blog_categories)\n .set({\n title,\n titleSeo: removeSpecialCharacters(title),\n })\n .where(eq(blog_categories.id, id))\n .returning();\n\n return c.json(category);\n },\n});\n"],"mappings":"+bAWA,MAAM,EAA4B,EAAE,OAAO,CACzC,GAAI,EAAE,OAAO,EACb,MAAO,EAAE,OAAO,EAChB,UAAW,EAAE,KAAK,EAClB,UAAW,EAAE,KAAK,CACpB,CAAC,EAEY,EAAoB,EAAW,CAC1C,SAAU,EAAc,SACxB,qBAAsB,CAAE,OAAQ,aAAc,WAAY,UAAW,EACrE,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,+BACf,EACA,IAAK,CACH,YAAa,kCACf,EACA,IAAK,CACH,YAAa,oBACf,CACF,CACF,EACA,QAAS,KAAM,IAAK,CAClB,GAAM,CAAE,MAAO,EAAE,IAAI,MAAM,OAAO,EAC5B,CAAE,SAAU,EAAE,IAAI,MAAM,MAAM,EAC9B,EAAW,EAAwB,CAAK,EACxC,CAAC,GAAY,MAAM,EACtB,IAAI,IAAI,CAAC,CACT,OAAO,CACN,SAAU,EAAgB,QAC5B,CAAC,CAAC,CACD,KAAK,CAAe,CAAC,CACrB,MAAM,EAAG,EAAgB,GAAI,CAAE,CAAC,CAAC,CACjC,MAAM,CAAC,EAEV,GAAI,CAAC,EACH,MAAM,IAAI,EAAc,GAAG,EAG7B,GAAM,CAAC,GAAqB,MAAM,EAC/B,IAAI,IAAI,CAAC,CACT,OAAO,CACN,SAAU,EAAgB,QAC5B,CAAC,CAAC,CACD,KAAK,CAAe,CAAC,CACrB,MAAM,EAAG,EAAgB,SAAU,CAAQ,CAAC,CAAC,CAC7C,MAAM,CAAC,EAEV,GACE,GAAmB,WAAa,GAChC,EAAkB,WAAa,EAAS,SAExC,MAAM,IAAI,EAAc,IAAK,CAC3B,QAAS,0CACX,CAAC,EAGH,GAAM,CAAC,GAAY,MAAM,EACtB,IAAI,IAAI,CAAC,CACT,OAAO,CAAe,CAAC,CACvB,IAAI,CACH,QACA,SAAU,EAAwB,CAAK,CACzC,CAAC,CAAC,CACD,MAAM,EAAG,EAAgB,GAAI,CAAE,CAAC,CAAC,CACjC,UAAU,EAEb,OAAO,EAAE,KAAK,CAAQ,CACxB,CACF,CAAC"}
|
|
@@ -1,107 +1,110 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
1
|
+
//#region src/api/modules/admin/posts/posts.admin.module.d.ts
|
|
2
|
+
declare const postsAdminModule: import("@vitnode/core/api/lib/module").BuildModuleReturn<"@vitnode/blog", "posts", [import("@vitnode/core/api/lib/route").Route<"@vitnode/blog", {
|
|
3
|
+
method: "put";
|
|
4
|
+
path: "/{id}";
|
|
5
|
+
request: {
|
|
6
|
+
params: import("zod").ZodObject<{
|
|
7
|
+
id: import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<number, string>>;
|
|
8
|
+
}, import("zod/v4/core").$strip>;
|
|
9
|
+
body: {
|
|
10
|
+
content: {
|
|
11
|
+
"application/json": {
|
|
12
|
+
schema: import("zod").ZodObject<{
|
|
13
|
+
title: import("zod").ZodString;
|
|
14
|
+
content: import("zod").ZodString;
|
|
15
|
+
categoryId: import("zod").ZodNumber;
|
|
16
|
+
}, import("zod/v4/core").$strip>;
|
|
18
17
|
};
|
|
18
|
+
};
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
35
|
-
description: string;
|
|
36
|
-
};
|
|
37
|
-
400: {
|
|
38
|
-
description: string;
|
|
39
|
-
};
|
|
40
|
-
404: {
|
|
41
|
-
description: string;
|
|
20
|
+
};
|
|
21
|
+
responses: {
|
|
22
|
+
200: {
|
|
23
|
+
content: {
|
|
24
|
+
"application/json": {
|
|
25
|
+
schema: import("zod").ZodObject<{
|
|
26
|
+
id: import("zod").ZodNumber;
|
|
27
|
+
title: import("zod").ZodString;
|
|
28
|
+
titleSeo: import("zod").ZodString;
|
|
29
|
+
content: import("zod").ZodString;
|
|
30
|
+
categoryId: import("zod").ZodNumber;
|
|
31
|
+
createdAt: import("zod").ZodDate;
|
|
32
|
+
updatedAt: import("zod").ZodDate;
|
|
33
|
+
}, import("zod/v4/core").$strip>;
|
|
42
34
|
};
|
|
35
|
+
};
|
|
36
|
+
description: string;
|
|
37
|
+
};
|
|
38
|
+
400: {
|
|
39
|
+
description: string;
|
|
43
40
|
};
|
|
41
|
+
404: {
|
|
42
|
+
description: string;
|
|
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
|
-
|
|
58
|
-
};
|
|
59
|
-
};
|
|
48
|
+
method: "post";
|
|
49
|
+
path: "/";
|
|
50
|
+
request: {
|
|
51
|
+
body: {
|
|
52
|
+
content: {
|
|
53
|
+
"application/json": {
|
|
54
|
+
schema: import("zod").ZodObject<{
|
|
55
|
+
title: import("zod").ZodString;
|
|
56
|
+
content: import("zod").ZodString;
|
|
57
|
+
categoryId: import("zod").ZodNumber;
|
|
58
|
+
}, import("zod/v4/core").$strip>;
|
|
60
59
|
};
|
|
60
|
+
};
|
|
61
61
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
77
|
-
description: string;
|
|
78
|
-
};
|
|
79
|
-
400: {
|
|
80
|
-
description: string;
|
|
81
|
-
};
|
|
82
|
-
404: {
|
|
83
|
-
description: string;
|
|
62
|
+
};
|
|
63
|
+
responses: {
|
|
64
|
+
201: {
|
|
65
|
+
content: {
|
|
66
|
+
"application/json": {
|
|
67
|
+
schema: import("zod").ZodObject<{
|
|
68
|
+
id: import("zod").ZodNumber;
|
|
69
|
+
title: import("zod").ZodString;
|
|
70
|
+
titleSeo: import("zod").ZodString;
|
|
71
|
+
content: import("zod").ZodString;
|
|
72
|
+
categoryId: import("zod").ZodNumber;
|
|
73
|
+
createdAt: import("zod").ZodDate;
|
|
74
|
+
updatedAt: import("zod").ZodDate;
|
|
75
|
+
}, import("zod/v4/core").$strip>;
|
|
84
76
|
};
|
|
77
|
+
};
|
|
78
|
+
description: string;
|
|
79
|
+
};
|
|
80
|
+
400: {
|
|
81
|
+
description: string;
|
|
82
|
+
};
|
|
83
|
+
404: {
|
|
84
|
+
description: string;
|
|
85
85
|
};
|
|
86
|
+
};
|
|
86
87
|
} & {
|
|
87
|
-
|
|
88
|
+
path: string;
|
|
88
89
|
}>, import("@vitnode/core/api/lib/route").Route<"@vitnode/blog", {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
method: "delete";
|
|
91
|
+
path: "/{id}";
|
|
92
|
+
request: {
|
|
93
|
+
params: import("zod").ZodObject<{
|
|
94
|
+
id: import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<number, string>>;
|
|
95
|
+
}, import("zod/v4/core").$strip>;
|
|
96
|
+
};
|
|
97
|
+
responses: {
|
|
98
|
+
204: {
|
|
99
|
+
description: string;
|
|
95
100
|
};
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
description: string;
|
|
99
|
-
};
|
|
100
|
-
404: {
|
|
101
|
-
description: string;
|
|
102
|
-
};
|
|
101
|
+
404: {
|
|
102
|
+
description: string;
|
|
103
103
|
};
|
|
104
|
+
};
|
|
104
105
|
} & {
|
|
105
|
-
|
|
106
|
+
path: string;
|
|
106
107
|
}>], import("@vitnode/core/api/lib/module").BaseBuildModuleReturn<"@vitnode/blog", string, import("@vitnode/core/api/lib/route").Route<"@vitnode/blog", import("@hono/zod-openapi").RouteConfig>[]>[]>;
|
|
108
|
+
//#endregion
|
|
109
|
+
export { postsAdminModule };
|
|
107
110
|
//# sourceMappingURL=posts.admin.module.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posts.admin.module.d.ts","
|
|
1
|
+
{"version":3,"file":"posts.admin.module.d.ts","names":[],"sources":["../../../../../../src/api/modules/admin/posts/posts.admin.module.ts"],"mappings":";cAOa,yDAAgB,mFAAA"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{CONFIG_PLUGIN as e}from"../../../../const.js";import{createPostRoute as t}from"./routes/create.route.js";import{deletePostRoute as n}from"./routes/delete.route.js";import{editPostRoute as r}from"./routes/edit.route.js";import{buildModule as i}from"@vitnode/core/api/lib/module";const a=i({pluginId:e.pluginId,name:`posts`,routes:[r,t,n]});export{a as postsAdminModule};
|
|
2
|
+
//# sourceMappingURL=posts.admin.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"posts.admin.module.js","names":[],"sources":["../../../../../../src/api/modules/admin/posts/posts.admin.module.ts"],"sourcesContent":["import { buildModule } from \"@vitnode/core/api/lib/module\";\n\nimport { CONFIG_PLUGIN } from \"../../../../const\";\nimport { createPostRoute } from \"./routes/create.route\";\nimport { deletePostRoute } from \"./routes/delete.route\";\nimport { editPostRoute } from \"./routes/edit.route\";\n\nexport const postsAdminModule = buildModule({\n pluginId: CONFIG_PLUGIN.pluginId,\n name: \"posts\",\n routes: [editPostRoute, createPostRoute, deletePostRoute],\n});\n"],"mappings":"6RAOA,MAAa,EAAmB,EAAY,CAC1C,SAAU,EAAc,SACxB,KAAM,QACN,OAAQ,CAAC,EAAe,EAAiB,CAAe,CAC1D,CAAC"}
|
|
@@ -1,50 +1,53 @@
|
|
|
1
1
|
import { z } from "@hono/zod-openapi";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
//#region src/api/modules/admin/posts/routes/create.route.d.ts
|
|
3
|
+
declare const zodCreatePostSchema: z.ZodObject<{
|
|
4
|
+
title: z.ZodString;
|
|
5
|
+
content: z.ZodString;
|
|
6
|
+
categoryId: z.ZodNumber;
|
|
6
7
|
}, z.core.$strip>;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
};
|
|
8
|
+
declare const createPostRoute: import("@vitnode/core/api/lib/route").Route<"@vitnode/blog", {
|
|
9
|
+
method: "post";
|
|
10
|
+
path: "/";
|
|
11
|
+
request: {
|
|
12
|
+
body: {
|
|
13
|
+
content: {
|
|
14
|
+
"application/json": {
|
|
15
|
+
schema: z.ZodObject<{
|
|
16
|
+
title: z.ZodString;
|
|
17
|
+
content: z.ZodString;
|
|
18
|
+
categoryId: z.ZodNumber;
|
|
19
|
+
}, z.core.$strip>;
|
|
21
20
|
};
|
|
21
|
+
};
|
|
22
22
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
38
|
-
description: string;
|
|
39
|
-
};
|
|
40
|
-
400: {
|
|
41
|
-
description: string;
|
|
42
|
-
};
|
|
43
|
-
404: {
|
|
44
|
-
description: string;
|
|
23
|
+
};
|
|
24
|
+
responses: {
|
|
25
|
+
201: {
|
|
26
|
+
content: {
|
|
27
|
+
"application/json": {
|
|
28
|
+
schema: z.ZodObject<{
|
|
29
|
+
id: z.ZodNumber;
|
|
30
|
+
title: z.ZodString;
|
|
31
|
+
titleSeo: z.ZodString;
|
|
32
|
+
content: z.ZodString;
|
|
33
|
+
categoryId: z.ZodNumber;
|
|
34
|
+
createdAt: z.ZodDate;
|
|
35
|
+
updatedAt: z.ZodDate;
|
|
36
|
+
}, z.core.$strip>;
|
|
45
37
|
};
|
|
38
|
+
};
|
|
39
|
+
description: string;
|
|
40
|
+
};
|
|
41
|
+
400: {
|
|
42
|
+
description: string;
|
|
43
|
+
};
|
|
44
|
+
404: {
|
|
45
|
+
description: string;
|
|
46
46
|
};
|
|
47
|
+
};
|
|
47
48
|
} & {
|
|
48
|
-
|
|
49
|
+
path: string;
|
|
49
50
|
}>;
|
|
51
|
+
//#endregion
|
|
52
|
+
export { createPostRoute, zodCreatePostSchema };
|
|
50
53
|
//# sourceMappingURL=create.route.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.route.d.ts","
|
|
1
|
+
{"version":3,"file":"create.route.d.ts","names":[],"sources":["../../../../../../../src/api/modules/admin/posts/routes/create.route.ts"],"mappings":";;cAoBa,qBAAmB,EAAA;;;;;cASnB,uDAAe"}
|
|
@@ -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{z as r}from"@hono/zod-openapi";import{buildRoute as i}from"@vitnode/core/api/lib/route";import{removeSpecialCharacters as a}from"@vitnode/core/lib/special-characters";import{eq as o}from"drizzle-orm";import{HTTPException as s}from"hono/http-exception";const c=r.object({id:r.number(),title:r.string(),titleSeo:r.string(),content:r.string(),categoryId:r.number(),createdAt:r.date(),updatedAt:r.date()}),l=r.object({title:r.string().min(3,`Title must be at least 3 characters long`).max(255,`Title must not exceed 255 characters`),content:r.string(),categoryId:r.number()}),u=i({pluginId:e.pluginId,adminStaffPermission:{module:`posts`,permission:`can_create`},route:{method:`post`,path:`/`,request:{body:{content:{"application/json":{schema:l}}}},responses:{201:{content:{"application/json":{schema:c}},description:`Post created successfully`},400:{description:`Bad request - Invalid input data`},404:{description:`Category not found`}}},handler:async e=>{let{title:r,content:i,categoryId:c}=e.req.valid(`json`),l=a(r),[u]=await e.get(`db`).select({id:t.id}).from(t).where(o(t.id,c)).limit(1);if(!u)throw new s(404,{message:`Category not found.`});let[d]=await e.get(`db`).select({titleSeo:n.titleSeo}).from(n).where(o(n.titleSeo,l)).limit(1);if(d?.titleSeo===l)throw new s(400,{message:`Post with this title already exists.`});let[f]=await e.get(`db`).insert(n).values({title:r,titleSeo:l,content:i,categoryId:c}).returning();return e.json(f,201)}});export{u as createPostRoute,l as zodCreatePostSchema};
|
|
2
|
+
//# sourceMappingURL=create.route.js.map
|