@vitnode/blog 1.2.0-canary.22 → 1.2.0-canary.24

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 (91) hide show
  1. package/dist/src/api/modules/admin/admin.module.d.ts +439 -0
  2. package/dist/src/api/modules/admin/admin.module.d.ts.map +1 -0
  3. package/dist/src/api/modules/admin/admin.module.js +1 -0
  4. package/dist/src/api/modules/admin/categories/categories.admin.module.d.ts +198 -0
  5. package/dist/src/api/modules/admin/categories/categories.admin.module.d.ts.map +1 -0
  6. package/dist/src/api/modules/admin/categories/categories.admin.module.js +1 -0
  7. package/dist/src/api/modules/{categories → admin/categories}/routes/create.route.d.ts +1 -1
  8. package/dist/src/api/modules/admin/categories/routes/create.route.d.ts.map +1 -0
  9. package/dist/src/api/modules/admin/categories/routes/create.route.js +1 -0
  10. package/dist/src/api/modules/{categories → admin/categories}/routes/delete.route.d.ts +1 -1
  11. package/dist/src/api/modules/admin/categories/routes/delete.route.d.ts.map +1 -0
  12. package/dist/src/api/modules/admin/categories/routes/delete.route.js +1 -0
  13. package/dist/src/api/modules/{categories → admin/categories}/routes/edit.route.d.ts +1 -1
  14. package/dist/src/api/modules/admin/categories/routes/edit.route.d.ts.map +1 -0
  15. package/dist/src/api/modules/admin/categories/routes/edit.route.js +1 -0
  16. package/dist/src/api/modules/admin/posts/posts.admin.module.d.ts +243 -0
  17. package/dist/src/api/modules/admin/posts/posts.admin.module.d.ts.map +1 -0
  18. package/dist/src/api/modules/admin/posts/posts.admin.module.js +1 -0
  19. package/dist/src/api/modules/{posts → admin/posts}/routes/create.route.d.ts +1 -1
  20. package/dist/src/api/modules/admin/posts/routes/create.route.d.ts.map +1 -0
  21. package/dist/src/api/modules/admin/posts/routes/create.route.js +1 -0
  22. package/dist/src/api/modules/{posts → admin/posts}/routes/delete.route.d.ts +1 -1
  23. package/dist/src/api/modules/admin/posts/routes/delete.route.d.ts.map +1 -0
  24. package/dist/src/api/modules/admin/posts/routes/delete.route.js +1 -0
  25. package/dist/src/api/modules/{posts → admin/posts}/routes/edit.route.d.ts +1 -1
  26. package/dist/src/api/modules/admin/posts/routes/edit.route.d.ts.map +1 -0
  27. package/dist/src/api/modules/admin/posts/routes/edit.route.js +1 -0
  28. package/dist/src/api/modules/categories/categories.module.d.ts +6 -197
  29. package/dist/src/api/modules/categories/categories.module.d.ts.map +1 -1
  30. package/dist/src/api/modules/categories/categories.module.js +1 -1
  31. package/dist/src/api/modules/categories/routes/get.route.d.ts +6 -1
  32. package/dist/src/api/modules/categories/routes/get.route.d.ts.map +1 -1
  33. package/dist/src/api/modules/categories/routes/get.route.js +1 -1
  34. package/dist/src/api/modules/posts/posts.module.d.ts +5 -246
  35. package/dist/src/api/modules/posts/posts.module.d.ts.map +1 -1
  36. package/dist/src/api/modules/posts/posts.module.js +1 -1
  37. package/dist/src/api/modules/posts/routes/get.route.d.ts +53 -5
  38. package/dist/src/api/modules/posts/routes/get.route.d.ts.map +1 -1
  39. package/dist/src/api/modules/posts/routes/get.route.js +1 -1
  40. package/dist/src/app_admin/blog/categories/page.d.ts +5 -1
  41. package/dist/src/app_admin/blog/categories/page.d.ts.map +1 -1
  42. package/dist/src/app_admin/blog/categories/page.js +1 -1
  43. package/dist/src/app_admin/blog/posts/page.d.ts +5 -1
  44. package/dist/src/app_admin/blog/posts/page.d.ts.map +1 -1
  45. package/dist/src/app_admin/blog/posts/page.js +1 -1
  46. package/dist/src/config.api.d.ts.map +1 -1
  47. package/dist/src/config.api.js +1 -1
  48. package/dist/src/views/admin/categories/actions/create-edit/create-edit.d.ts +1 -1
  49. package/dist/src/views/admin/categories/actions/create-edit/create-edit.d.ts.map +1 -1
  50. package/dist/src/views/admin/categories/actions/create-edit/create-edit.js +1 -1
  51. package/dist/src/views/admin/categories/actions/create-edit/mutation-api.d.ts +1 -1
  52. package/dist/src/views/admin/categories/actions/create-edit/mutation-api.d.ts.map +1 -1
  53. package/dist/src/views/admin/categories/actions/create-edit/mutation-api.js +1 -1
  54. package/dist/src/views/admin/categories/row-actions/delete/delete-action.d.ts.map +1 -1
  55. package/dist/src/views/admin/categories/row-actions/delete/delete-action.js +1 -1
  56. package/dist/src/views/admin/categories/row-actions/delete/mutation-api.d.ts.map +1 -1
  57. package/dist/src/views/admin/categories/row-actions/delete/mutation-api.js +1 -1
  58. package/dist/src/views/admin/categories/row-actions/edit-action.d.ts +1 -1
  59. package/dist/src/views/admin/categories/row-actions/edit-action.d.ts.map +1 -1
  60. package/dist/src/views/admin/posts/actions/create-edit/create-edit.d.ts +2 -2
  61. package/dist/src/views/admin/posts/actions/create-edit/create-edit.d.ts.map +1 -1
  62. package/dist/src/views/admin/posts/actions/create-edit/create-edit.js +1 -1
  63. package/dist/src/views/admin/posts/actions/create-edit/mutation-api.d.ts +11 -0
  64. package/dist/src/views/admin/posts/actions/create-edit/mutation-api.d.ts.map +1 -0
  65. package/dist/src/views/admin/posts/actions/create-edit/mutation-api.js +1 -0
  66. package/dist/src/views/admin/posts/posts-admin-view.d.ts.map +1 -1
  67. package/dist/src/views/admin/posts/posts-admin-view.js +1 -1
  68. package/dist/src/views/admin/posts/row-actions/delete/delete-action.d.ts.map +1 -1
  69. package/dist/src/views/admin/posts/row-actions/delete/delete-action.js +1 -1
  70. package/dist/src/views/admin/posts/row-actions/delete/mutation-api.d.ts.map +1 -1
  71. package/dist/src/views/admin/posts/row-actions/delete/mutation-api.js +1 -1
  72. package/dist/src/views/admin/posts/row-actions/edit-action.d.ts +9 -0
  73. package/dist/src/views/admin/posts/row-actions/edit-action.d.ts.map +1 -0
  74. package/dist/src/views/admin/posts/row-actions/edit-action.js +1 -0
  75. package/dist/tsconfig.tsbuildinfo +1 -1
  76. package/package.json +16 -16
  77. package/src/app_admin/blog/categories/page.tsx +12 -4
  78. package/src/app_admin/blog/posts/page.tsx +12 -3
  79. package/src/locales/en.json +6 -2
  80. package/dist/src/api/modules/categories/routes/create.route.d.ts.map +0 -1
  81. package/dist/src/api/modules/categories/routes/create.route.js +0 -1
  82. package/dist/src/api/modules/categories/routes/delete.route.d.ts.map +0 -1
  83. package/dist/src/api/modules/categories/routes/delete.route.js +0 -1
  84. package/dist/src/api/modules/categories/routes/edit.route.d.ts.map +0 -1
  85. package/dist/src/api/modules/categories/routes/edit.route.js +0 -1
  86. package/dist/src/api/modules/posts/routes/create.route.d.ts.map +0 -1
  87. package/dist/src/api/modules/posts/routes/create.route.js +0 -1
  88. package/dist/src/api/modules/posts/routes/delete.route.d.ts.map +0 -1
  89. package/dist/src/api/modules/posts/routes/delete.route.js +0 -1
  90. package/dist/src/api/modules/posts/routes/edit.route.d.ts.map +0 -1
  91. package/dist/src/api/modules/posts/routes/edit.route.js +0 -1
@@ -1,6 +1,6 @@
1
1
  import { z } from '@hono/zod-openapi';
2
2
  export declare const editCategoryRoute: {
3
- handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global/global").EnvVitNode, "/:id", {
3
+ handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global.middleware").EnvVitNode, "/:id", {
4
4
  in: {
5
5
  param: {
6
6
  id: string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit.route.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/modules/admin/categories/routes/edit.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAkBtC,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiF5B,CAAC"}
@@ -0,0 +1 @@
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{zodCreateCategorySchema}from"./create.route.js";const zodCategoryResponseSchema=z.object({id:z.number(),title:z.string(),createdAt:z.date(),updatedAt:z.date()});export const editCategoryRoute=buildRoute({...CONFIG_PLUGIN,route:{method:"put",path:"/{id}",request:{params:z.object({id:z.string().transform(Number)}),body:{content:{"application/json":{schema:zodCreateCategorySchema}}}},responses:{200:{content:{"application/json":{schema:zodCategoryResponseSchema}},description:"Category updated successfully"},400:{description:"Bad request - Invalid input data"},404:{description:"Category not found"}}},handler:async c=>{const{id}=c.req.valid("param");const{title}=c.req.valid("json");const titleSeo=removeSpecialCharacters(title);const[editData]=await c.get("db").select({titleSeo:blog_categories.titleSeo}).from(blog_categories).where(eq(blog_categories.id,id)).limit(1);if(!editData){throw new HTTPException(404)}const[titleSEODuplocate]=await c.get("db").select({titleSeo:blog_categories.titleSeo}).from(blog_categories).where(eq(blog_categories.titleSeo,titleSeo)).limit(1);if(titleSEODuplocate?.titleSeo===titleSeo&&titleSEODuplocate.titleSeo!==editData.titleSeo){throw new HTTPException(400,{message:"Category with this title already exists."})}const[category]=await c.get("db").update(blog_categories).set({title,titleSeo:removeSpecialCharacters(title)}).where(eq(blog_categories.id,id)).returning();return c.json(category)}});
@@ -0,0 +1,243 @@
1
+ export declare const postsAdminModule: import("@vitnode/core/api/lib/module").BuildModuleReturn<"@vitnode/blog", "posts", [{
2
+ handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global.middleware").EnvVitNode, "/:id", {
3
+ in: {
4
+ param: {
5
+ id: string;
6
+ };
7
+ };
8
+ out: {
9
+ param: {
10
+ id: number;
11
+ };
12
+ };
13
+ } & {
14
+ in: {
15
+ json: {
16
+ title: string;
17
+ content: string;
18
+ categoryId: number;
19
+ };
20
+ };
21
+ out: {
22
+ json: {
23
+ title: string;
24
+ content: string;
25
+ categoryId: number;
26
+ };
27
+ };
28
+ }>) => Promise<Response & import("hono").TypedResponse<{
29
+ id: number;
30
+ title: string;
31
+ titleSeo: string;
32
+ content: string;
33
+ categoryId: number;
34
+ createdAt: string;
35
+ updatedAt: string;
36
+ }, 400 | 200 | 404, "json">>;
37
+ pluginId: "@vitnode/blog";
38
+ route: {
39
+ method: "put";
40
+ path: "/{id}";
41
+ request: {
42
+ params: import("zod").ZodObject<{
43
+ id: import("zod").ZodEffects<import("zod").ZodString, number, string>;
44
+ }, "strip", import("zod").ZodTypeAny, {
45
+ id: number;
46
+ }, {
47
+ id: string;
48
+ }>;
49
+ body: {
50
+ content: {
51
+ 'application/json': {
52
+ schema: import("zod").ZodObject<{
53
+ title: import("zod").ZodString;
54
+ content: import("zod").ZodString;
55
+ categoryId: import("zod").ZodNumber;
56
+ }, "strip", import("zod").ZodTypeAny, {
57
+ title: string;
58
+ content: string;
59
+ categoryId: number;
60
+ }, {
61
+ title: string;
62
+ content: string;
63
+ categoryId: number;
64
+ }>;
65
+ };
66
+ };
67
+ };
68
+ };
69
+ responses: {
70
+ 200: {
71
+ content: {
72
+ 'application/json': {
73
+ schema: import("zod").ZodObject<{
74
+ id: import("zod").ZodNumber;
75
+ title: import("zod").ZodString;
76
+ titleSeo: import("zod").ZodString;
77
+ content: import("zod").ZodString;
78
+ categoryId: import("zod").ZodNumber;
79
+ createdAt: import("zod").ZodDate;
80
+ updatedAt: import("zod").ZodDate;
81
+ }, "strip", import("zod").ZodTypeAny, {
82
+ id: number;
83
+ title: string;
84
+ createdAt: Date;
85
+ updatedAt: Date;
86
+ titleSeo: string;
87
+ content: string;
88
+ categoryId: number;
89
+ }, {
90
+ id: number;
91
+ title: string;
92
+ createdAt: Date;
93
+ updatedAt: Date;
94
+ titleSeo: string;
95
+ content: string;
96
+ categoryId: number;
97
+ }>;
98
+ };
99
+ };
100
+ description: string;
101
+ };
102
+ 400: {
103
+ description: string;
104
+ };
105
+ 404: {
106
+ description: string;
107
+ };
108
+ };
109
+ } & {
110
+ getRoutingPath: () => "/:id";
111
+ };
112
+ }, {
113
+ handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global.middleware").EnvVitNode, "/", {
114
+ in: {
115
+ json: {
116
+ title: string;
117
+ content: string;
118
+ categoryId: number;
119
+ };
120
+ };
121
+ out: {
122
+ json: {
123
+ title: string;
124
+ content: string;
125
+ categoryId: number;
126
+ };
127
+ };
128
+ }>) => Promise<Response & import("hono").TypedResponse<{
129
+ id: number;
130
+ title: string;
131
+ createdAt: string;
132
+ updatedAt: string;
133
+ titleSeo: string;
134
+ content: string;
135
+ categoryId: number;
136
+ }, 201, "json">>;
137
+ pluginId: "@vitnode/blog";
138
+ route: {
139
+ method: "post";
140
+ path: "/";
141
+ request: {
142
+ body: {
143
+ content: {
144
+ 'application/json': {
145
+ schema: import("zod").ZodObject<{
146
+ title: import("zod").ZodString;
147
+ content: import("zod").ZodString;
148
+ categoryId: import("zod").ZodNumber;
149
+ }, "strip", import("zod").ZodTypeAny, {
150
+ title: string;
151
+ content: string;
152
+ categoryId: number;
153
+ }, {
154
+ title: string;
155
+ content: string;
156
+ categoryId: number;
157
+ }>;
158
+ };
159
+ };
160
+ };
161
+ };
162
+ responses: {
163
+ 201: {
164
+ content: {
165
+ 'application/json': {
166
+ schema: import("zod").ZodObject<{
167
+ id: import("zod").ZodNumber;
168
+ title: import("zod").ZodString;
169
+ titleSeo: import("zod").ZodString;
170
+ content: import("zod").ZodString;
171
+ categoryId: import("zod").ZodNumber;
172
+ createdAt: import("zod").ZodDate;
173
+ updatedAt: import("zod").ZodDate;
174
+ }, "strip", import("zod").ZodTypeAny, {
175
+ id: number;
176
+ title: string;
177
+ createdAt: Date;
178
+ updatedAt: Date;
179
+ titleSeo: string;
180
+ content: string;
181
+ categoryId: number;
182
+ }, {
183
+ id: number;
184
+ title: string;
185
+ createdAt: Date;
186
+ updatedAt: Date;
187
+ titleSeo: string;
188
+ content: string;
189
+ categoryId: number;
190
+ }>;
191
+ };
192
+ };
193
+ description: string;
194
+ };
195
+ 400: {
196
+ description: string;
197
+ };
198
+ 404: {
199
+ description: string;
200
+ };
201
+ };
202
+ } & {
203
+ getRoutingPath: () => "/";
204
+ };
205
+ }, {
206
+ handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global.middleware").EnvVitNode, "/:id", {
207
+ in: {
208
+ param: {
209
+ id: string;
210
+ };
211
+ };
212
+ out: {
213
+ param: {
214
+ id: number;
215
+ };
216
+ };
217
+ }>) => Promise<Response & import("hono").TypedResponse<null, 204, "body">>;
218
+ pluginId: "@vitnode/blog";
219
+ route: {
220
+ method: "delete";
221
+ path: "/{id}";
222
+ request: {
223
+ params: import("zod").ZodObject<{
224
+ id: import("zod").ZodEffects<import("zod").ZodString, number, string>;
225
+ }, "strip", import("zod").ZodTypeAny, {
226
+ id: number;
227
+ }, {
228
+ id: string;
229
+ }>;
230
+ };
231
+ responses: {
232
+ 204: {
233
+ description: string;
234
+ };
235
+ 404: {
236
+ description: string;
237
+ };
238
+ };
239
+ } & {
240
+ getRoutingPath: () => "/:id";
241
+ };
242
+ }], import("@vitnode/core/api/lib/module").BaseBuildModuleReturn<"@vitnode/blog", string, import("@vitnode/core/api/lib/route").Route<"@vitnode/blog", import("@hono/zod-openapi").RouteConfig, import("@hono/zod-openapi").RouteHandler<import("@hono/zod-openapi").RouteConfig>>[]>[]>;
243
+ //# sourceMappingURL=posts.admin.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"posts.admin.module.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/admin/posts/posts.admin.module.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wRAI3B,CAAC"}
@@ -0,0 +1 @@
1
+ import{buildModule}from"@vitnode/core/api/lib/module";import{CONFIG_PLUGIN}from"../../../../const.js";import{createPostRoute}from"./routes/create.route.js";import{deletePostRoute}from"./routes/delete.route.js";import{editPostRoute}from"./routes/edit.route.js";export const postsAdminModule=buildModule({...CONFIG_PLUGIN,name:"posts",routes:[editPostRoute,createPostRoute,deletePostRoute]});
@@ -13,7 +13,7 @@ export declare const zodCreatePostSchema: z.ZodObject<{
13
13
  categoryId: number;
14
14
  }>;
15
15
  export declare const createPostRoute: {
16
- handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global/global").EnvVitNode, "/", {
16
+ handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global.middleware").EnvVitNode, "/", {
17
17
  in: {
18
18
  json: {
19
19
  title: string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.route.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/modules/admin/posts/routes/create.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAUtC,eAAO,MAAM,mBAAmB;;;;;;;;;;;;EAO9B,CAAC;AAYH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4E1B,CAAC"}
@@ -0,0 +1 @@
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";export const zodCreatePostSchema=z.object({title:z.string().min(3,"Title must be at least 3 characters long").max(255,"Title must not exceed 255 characters"),content:z.string(),categoryId:z.number()});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 createPostRoute=buildRoute({...CONFIG_PLUGIN,route:{method:"post",path:"/",request:{body:{content:{"application/json":{schema:zodCreatePostSchema}}}},responses:{201:{content:{"application/json":{schema:zodPostResponseSchema}},description:"Post created successfully"},400:{description:"Bad request - Invalid input data"},404:{description:"Category not found"}}},handler:async c=>{const{title,content,categoryId}=c.req.valid("json");const titleSeo=removeSpecialCharacters(title);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){throw new HTTPException(400,{message:"Post with this title already exists."})}const[post]=await c.get("db").insert(blog_posts).values({title,titleSeo,content,categoryId}).returning();return c.json(post,201)}});
@@ -1,6 +1,6 @@
1
1
  import { z } from '@hono/zod-openapi';
2
2
  export declare const deletePostRoute: {
3
- handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global/global").EnvVitNode, "/:id", {
3
+ handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global.middleware").EnvVitNode, "/:id", {
4
4
  in: {
5
5
  param: {
6
6
  id: string;
@@ -0,0 +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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkC1B,CAAC"}
@@ -0,0 +1 @@
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({...CONFIG_PLUGIN,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,6 +1,6 @@
1
1
  import { z } from '@hono/zod-openapi';
2
2
  export declare const editPostRoute: {
3
- handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global/global").EnvVitNode, "/:id", {
3
+ handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global.middleware").EnvVitNode, "/:id", {
4
4
  in: {
5
5
  param: {
6
6
  id: string;
@@ -0,0 +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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8FxB,CAAC"}
@@ -0,0 +1 @@
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({...CONFIG_PLUGIN,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,7 +1,8 @@
1
1
  export declare const categoriesModule: import("@vitnode/core/api/lib/module").BuildModuleReturn<"@vitnode/blog", "categories", [{
2
- handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global/global").EnvVitNode, "/", {
2
+ handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global.middleware").EnvVitNode, "/", {
3
3
  in: {
4
4
  query: {
5
+ search?: string | undefined;
5
6
  orderBy?: "updatedAt" | undefined;
6
7
  cursor?: string | undefined;
7
8
  first?: string | undefined;
@@ -11,6 +12,7 @@ export declare const categoriesModule: import("@vitnode/core/api/lib/module").Bu
11
12
  };
12
13
  out: {
13
14
  query: {
15
+ search?: string | undefined;
14
16
  orderBy?: "updatedAt" | undefined;
15
17
  cursor?: string | undefined;
16
18
  first?: string | undefined;
@@ -47,13 +49,16 @@ export declare const categoriesModule: import("@vitnode/core/api/lib/module").Bu
47
49
  } & {
48
50
  order: import("zod").ZodOptional<import("zod").ZodEnum<["asc", "desc"]>>;
49
51
  orderBy: import("zod").ZodOptional<import("zod").ZodEnum<["updatedAt"]>>;
52
+ search: import("zod").ZodOptional<import("zod").ZodString>;
50
53
  }, "strip", import("zod").ZodTypeAny, {
54
+ search?: string | undefined;
51
55
  orderBy?: "updatedAt" | undefined;
52
56
  cursor?: string | undefined;
53
57
  first?: string | undefined;
54
58
  last?: string | undefined;
55
59
  order?: "asc" | "desc" | undefined;
56
60
  }, {
61
+ search?: string | undefined;
57
62
  orderBy?: "updatedAt" | undefined;
58
63
  cursor?: string | undefined;
59
64
  first?: string | undefined;
@@ -143,201 +148,5 @@ export declare const categoriesModule: import("@vitnode/core/api/lib/module").Bu
143
148
  } & {
144
149
  getRoutingPath: () => "/";
145
150
  };
146
- }, {
147
- handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global/global").EnvVitNode, "/", {
148
- in: {
149
- json: {
150
- title: string;
151
- };
152
- };
153
- out: {
154
- json: {
155
- title: string;
156
- };
157
- };
158
- }>) => Promise<Response & import("hono").TypedResponse<{
159
- id: number;
160
- title: string;
161
- createdAt: string;
162
- updatedAt: string;
163
- titleSeo: string;
164
- }, 201, "json">>;
165
- pluginId: "@vitnode/blog";
166
- route: {
167
- method: "post";
168
- path: "/";
169
- request: {
170
- body: {
171
- content: {
172
- 'application/json': {
173
- schema: import("zod").ZodObject<{
174
- title: import("zod").ZodString;
175
- }, "strip", import("zod").ZodTypeAny, {
176
- title: string;
177
- }, {
178
- title: string;
179
- }>;
180
- };
181
- };
182
- };
183
- };
184
- responses: {
185
- 201: {
186
- content: {
187
- 'application/json': {
188
- schema: import("zod").ZodObject<{
189
- id: import("zod").ZodNumber;
190
- title: import("zod").ZodString;
191
- createdAt: import("zod").ZodDate;
192
- updatedAt: import("zod").ZodDate;
193
- }, "strip", import("zod").ZodTypeAny, {
194
- id: number;
195
- title: string;
196
- createdAt: Date;
197
- updatedAt: Date;
198
- }, {
199
- id: number;
200
- title: string;
201
- createdAt: Date;
202
- updatedAt: Date;
203
- }>;
204
- };
205
- };
206
- description: string;
207
- };
208
- 400: {
209
- description: string;
210
- };
211
- };
212
- } & {
213
- getRoutingPath: () => "/";
214
- };
215
- }, {
216
- handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global/global").EnvVitNode, "/:id", {
217
- in: {
218
- param: {
219
- id: string;
220
- };
221
- };
222
- out: {
223
- param: {
224
- id: number;
225
- };
226
- };
227
- } & {
228
- in: {
229
- json: {
230
- title: string;
231
- };
232
- };
233
- out: {
234
- json: {
235
- title: string;
236
- };
237
- };
238
- }>) => Promise<Response & import("hono").TypedResponse<{
239
- id: number;
240
- title: string;
241
- createdAt: string;
242
- updatedAt: string;
243
- titleSeo: string;
244
- }, 400 | 200 | 404, "json">>;
245
- pluginId: "@vitnode/blog";
246
- route: {
247
- method: "put";
248
- path: "/{id}";
249
- request: {
250
- params: import("zod").ZodObject<{
251
- id: import("zod").ZodEffects<import("zod").ZodString, number, string>;
252
- }, "strip", import("zod").ZodTypeAny, {
253
- id: number;
254
- }, {
255
- id: string;
256
- }>;
257
- body: {
258
- content: {
259
- 'application/json': {
260
- schema: import("zod").ZodObject<{
261
- title: import("zod").ZodString;
262
- }, "strip", import("zod").ZodTypeAny, {
263
- title: string;
264
- }, {
265
- title: string;
266
- }>;
267
- };
268
- };
269
- };
270
- };
271
- responses: {
272
- 200: {
273
- content: {
274
- 'application/json': {
275
- schema: import("zod").ZodObject<{
276
- id: import("zod").ZodNumber;
277
- title: import("zod").ZodString;
278
- createdAt: import("zod").ZodDate;
279
- updatedAt: import("zod").ZodDate;
280
- }, "strip", import("zod").ZodTypeAny, {
281
- id: number;
282
- title: string;
283
- createdAt: Date;
284
- updatedAt: Date;
285
- }, {
286
- id: number;
287
- title: string;
288
- createdAt: Date;
289
- updatedAt: Date;
290
- }>;
291
- };
292
- };
293
- description: string;
294
- };
295
- 400: {
296
- description: string;
297
- };
298
- 404: {
299
- description: string;
300
- };
301
- };
302
- } & {
303
- getRoutingPath: () => "/:id";
304
- };
305
- }, {
306
- handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global/global").EnvVitNode, "/:id", {
307
- in: {
308
- param: {
309
- id: string;
310
- };
311
- };
312
- out: {
313
- param: {
314
- id: number;
315
- };
316
- };
317
- }>) => Promise<Response & import("hono").TypedResponse<null, 204, "body">>;
318
- pluginId: "@vitnode/blog";
319
- route: {
320
- method: "delete";
321
- path: "/{id}";
322
- request: {
323
- params: import("zod").ZodObject<{
324
- id: import("zod").ZodEffects<import("zod").ZodString, number, string>;
325
- }, "strip", import("zod").ZodTypeAny, {
326
- id: number;
327
- }, {
328
- id: string;
329
- }>;
330
- };
331
- responses: {
332
- 204: {
333
- description: string;
334
- };
335
- 404: {
336
- description: string;
337
- };
338
- };
339
- } & {
340
- getRoutingPath: () => "/:id";
341
- };
342
151
  }], import("@vitnode/core/api/lib/module").BaseBuildModuleReturn<"@vitnode/blog", string, import("@vitnode/core/api/lib/route").Route<"@vitnode/blog", import("@hono/zod-openapi").RouteConfig, import("@hono/zod-openapi").RouteHandler<import("@hono/zod-openapi").RouteConfig>>[]>[]>;
343
152
  //# 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":"AASA,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wRAS3B,CAAC"}
1
+ {"version":3,"file":"categories.module.d.ts","sourceRoot":"","sources":["../../../../../src/api/modules/categories/categories.module.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wRAI3B,CAAC"}
@@ -1 +1 @@
1
- import{buildModule}from"@vitnode/core/api/lib/module";import{CONFIG_PLUGIN}from"../../../const.js";import{createCategoryRoute}from"./routes/create.route.js";import{deleteCategoryRoute}from"./routes/delete.route.js";import{editCategoryRoute}from"./routes/edit.route.js";import{categoriesRoute}from"./routes/get.route.js";export const categoriesModule=buildModule({...CONFIG_PLUGIN,name:"categories",routes:[categoriesRoute,createCategoryRoute,editCategoryRoute,deleteCategoryRoute]});
1
+ import{buildModule}from"@vitnode/core/api/lib/module";import{CONFIG_PLUGIN}from"../../../const.js";import{categoriesRoute}from"./routes/get.route.js";export const categoriesModule=buildModule({...CONFIG_PLUGIN,name:"categories",routes:[categoriesRoute]});
@@ -1,8 +1,9 @@
1
1
  import { z } from '@hono/zod-openapi';
2
2
  export declare const categoriesRoute: {
3
- handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global/global").EnvVitNode, "/", {
3
+ handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global.middleware").EnvVitNode, "/", {
4
4
  in: {
5
5
  query: {
6
+ search?: string | undefined;
6
7
  orderBy?: "updatedAt" | undefined;
7
8
  cursor?: string | undefined;
8
9
  first?: string | undefined;
@@ -12,6 +13,7 @@ export declare const categoriesRoute: {
12
13
  };
13
14
  out: {
14
15
  query: {
16
+ search?: string | undefined;
15
17
  orderBy?: "updatedAt" | undefined;
16
18
  cursor?: string | undefined;
17
19
  first?: string | undefined;
@@ -48,13 +50,16 @@ export declare const categoriesRoute: {
48
50
  } & {
49
51
  order: z.ZodOptional<z.ZodEnum<["asc", "desc"]>>;
50
52
  orderBy: z.ZodOptional<z.ZodEnum<["updatedAt"]>>;
53
+ search: z.ZodOptional<z.ZodString>;
51
54
  }, "strip", z.ZodTypeAny, {
55
+ search?: string | undefined;
52
56
  orderBy?: "updatedAt" | undefined;
53
57
  cursor?: string | undefined;
54
58
  first?: string | undefined;
55
59
  last?: string | undefined;
56
60
  order?: "asc" | "desc" | undefined;
57
61
  }, {
62
+ search?: string | undefined;
58
63
  orderBy?: "updatedAt" | undefined;
59
64
  cursor?: string | undefined;
60
65
  first?: string | undefined;
@@ -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;AAkBtC,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqD1B,CAAC"}
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiE1B,CAAC"}
@@ -1 +1 @@
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{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({...CONFIG_PLUGIN,route:{method:"get",path:"/",request:{query:zodPaginationQuery.extend({order:z.enum(["asc","desc"]).optional(),orderBy:z.enum(["updatedAt"]).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})=>await c.get("db").select().from(blog_categories).where(where).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{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({...CONFIG_PLUGIN,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;const combinedWhere=searchCondition?where?and(where,searchCondition):searchCondition: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)}});