@vitnode/blog 1.2.0-canary.17 → 1.2.0-canary.18

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 (80) hide show
  1. package/dist/src/api/modules/categories/categories.module.d.ts +343 -0
  2. package/dist/src/api/modules/categories/categories.module.d.ts.map +1 -0
  3. package/dist/src/api/modules/categories/categories.module.js +1 -0
  4. package/dist/src/api/modules/categories/routes/create.route.d.ts +79 -0
  5. package/dist/src/api/modules/categories/routes/create.route.d.ts.map +1 -0
  6. package/dist/src/api/modules/categories/routes/create.route.js +1 -0
  7. package/dist/src/api/modules/categories/routes/delete.route.d.ts +40 -0
  8. package/dist/src/api/modules/categories/routes/delete.route.d.ts.map +1 -0
  9. package/dist/src/api/modules/categories/routes/delete.route.js +1 -0
  10. package/dist/src/api/modules/categories/routes/edit.route.d.ts +100 -0
  11. package/dist/src/api/modules/categories/routes/edit.route.d.ts.map +1 -0
  12. package/dist/src/api/modules/categories/routes/edit.route.js +1 -0
  13. package/dist/src/api/modules/categories/routes/get.route.d.ts +148 -0
  14. package/dist/src/api/modules/categories/routes/get.route.d.ts.map +1 -0
  15. package/dist/src/api/modules/categories/routes/get.route.js +1 -0
  16. package/dist/src/api/modules/posts/posts.module.d.ts +448 -0
  17. package/dist/src/api/modules/posts/posts.module.d.ts.map +1 -0
  18. package/dist/src/api/modules/posts/posts.module.js +1 -0
  19. package/dist/src/api/modules/posts/routes/create.route.d.ts +109 -0
  20. package/dist/src/api/modules/posts/routes/create.route.d.ts.map +1 -0
  21. package/dist/src/api/modules/posts/routes/create.route.js +1 -0
  22. package/dist/src/api/modules/posts/routes/delete.route.d.ts +40 -0
  23. package/dist/src/api/modules/posts/routes/delete.route.d.ts.map +1 -0
  24. package/dist/src/api/modules/posts/routes/delete.route.js +1 -0
  25. package/dist/src/api/modules/posts/routes/edit.route.d.ts +127 -0
  26. package/dist/src/api/modules/posts/routes/edit.route.d.ts.map +1 -0
  27. package/dist/src/api/modules/posts/routes/edit.route.js +1 -0
  28. package/dist/src/api/modules/posts/routes/get.route.d.ts +208 -0
  29. package/dist/src/api/modules/posts/routes/get.route.d.ts.map +1 -0
  30. package/dist/src/api/modules/posts/routes/get.route.js +1 -0
  31. package/dist/src/app_admin/blog/categories/page.d.ts +5 -0
  32. package/dist/src/app_admin/blog/categories/page.d.ts.map +1 -0
  33. package/dist/src/app_admin/blog/categories/page.js +1 -0
  34. package/dist/src/config.api.d.ts +2 -0
  35. package/dist/src/config.api.d.ts.map +1 -0
  36. package/dist/src/config.api.js +1 -0
  37. package/dist/src/config.d.ts +4 -0
  38. package/dist/src/config.d.ts.map +1 -0
  39. package/dist/src/config.js +1 -0
  40. package/dist/src/database/categories.d.ts +97 -0
  41. package/dist/src/database/categories.d.ts.map +1 -0
  42. package/dist/src/database/categories.js +1 -0
  43. package/{src/database/index.ts → dist/src/database/index.d.ts} +1 -3
  44. package/dist/src/database/index.d.ts.map +1 -0
  45. package/dist/src/database/index.js +1 -0
  46. package/dist/src/database/posts.d.ts +131 -0
  47. package/dist/src/database/posts.d.ts.map +1 -0
  48. package/dist/src/database/posts.js +1 -0
  49. package/dist/src/database/relations.d.ts +7 -0
  50. package/dist/src/database/relations.d.ts.map +1 -0
  51. package/dist/src/database/relations.js +1 -0
  52. package/dist/src/plugin.d.ts +2 -0
  53. package/dist/src/plugin.d.ts.map +1 -0
  54. package/dist/src/plugin.js +1 -0
  55. package/dist/src/views/admin/categories/actions/actions.d.ts +2 -0
  56. package/dist/src/views/admin/categories/actions/actions.d.ts.map +1 -0
  57. package/dist/src/views/admin/categories/actions/actions.js +1 -0
  58. package/dist/src/views/admin/categories/actions/create-edit/create-edit.d.ts +8 -0
  59. package/dist/src/views/admin/categories/actions/create-edit/create-edit.d.ts.map +1 -0
  60. package/dist/src/views/admin/categories/actions/create-edit/create-edit.js +1 -0
  61. package/dist/src/views/admin/categories/actions/create-edit/mutation-api.d.ts +11 -0
  62. package/dist/src/views/admin/categories/actions/create-edit/mutation-api.d.ts.map +1 -0
  63. package/dist/src/views/admin/categories/actions/create-edit/mutation-api.js +1 -0
  64. package/dist/src/views/admin/categories/categories-admin-view.d.ts +4 -0
  65. package/dist/src/views/admin/categories/categories-admin-view.d.ts.map +1 -0
  66. package/dist/src/views/admin/categories/categories-admin-view.js +1 -0
  67. package/dist/src/views/admin/categories/row-actions/delete/delete-action.d.ts +5 -0
  68. package/dist/src/views/admin/categories/row-actions/delete/delete-action.d.ts.map +1 -0
  69. package/dist/src/views/admin/categories/row-actions/delete/delete-action.js +1 -0
  70. package/dist/src/views/admin/categories/row-actions/delete/mutation-api.d.ts +4 -0
  71. package/dist/src/views/admin/categories/row-actions/delete/mutation-api.d.ts.map +1 -0
  72. package/dist/src/views/admin/categories/row-actions/delete/mutation-api.js +1 -0
  73. package/dist/src/views/admin/categories/row-actions/edit-action.d.ts +9 -0
  74. package/dist/src/views/admin/categories/row-actions/edit-action.d.ts.map +1 -0
  75. package/dist/src/views/admin/categories/row-actions/edit-action.js +1 -0
  76. package/dist/tsconfig.tsbuildinfo +1 -0
  77. package/package.json +3 -3
  78. package/src/database/categories.ts +0 -12
  79. package/src/database/posts.ts +0 -19
  80. package/src/database/relations.ts +0 -18
@@ -0,0 +1,343 @@
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, "/", {
3
+ in: {
4
+ query: {
5
+ orderBy?: "updatedAt" | undefined;
6
+ cursor?: string | undefined;
7
+ first?: string | undefined;
8
+ last?: string | undefined;
9
+ order?: "asc" | "desc" | undefined;
10
+ };
11
+ };
12
+ out: {
13
+ query: {
14
+ orderBy?: "updatedAt" | undefined;
15
+ cursor?: string | undefined;
16
+ first?: string | undefined;
17
+ last?: string | undefined;
18
+ order?: "asc" | "desc" | undefined;
19
+ };
20
+ };
21
+ }>) => Promise<Response & import("hono").TypedResponse<{
22
+ edges: {
23
+ id: number;
24
+ title: string;
25
+ createdAt: string;
26
+ updatedAt: string;
27
+ titleSeo: string;
28
+ }[];
29
+ pageInfo: {
30
+ count: number;
31
+ endCursor: null | number;
32
+ hasNextPage: boolean;
33
+ hasPreviousPage: boolean;
34
+ startCursor: null | number;
35
+ totalCount: number;
36
+ };
37
+ }, 200, "json">>;
38
+ pluginId: "@vitnode/blog";
39
+ route: {
40
+ method: "get";
41
+ path: "/";
42
+ request: {
43
+ query: import("zod").ZodObject<{
44
+ cursor: import("zod").ZodOptional<import("zod").ZodString>;
45
+ first: import("zod").ZodOptional<import("zod").ZodString>;
46
+ last: import("zod").ZodOptional<import("zod").ZodString>;
47
+ } & {
48
+ order: import("zod").ZodOptional<import("zod").ZodEnum<["asc", "desc"]>>;
49
+ orderBy: import("zod").ZodOptional<import("zod").ZodEnum<["updatedAt"]>>;
50
+ }, "strip", import("zod").ZodTypeAny, {
51
+ orderBy?: "updatedAt" | undefined;
52
+ cursor?: string | undefined;
53
+ first?: string | undefined;
54
+ last?: string | undefined;
55
+ order?: "asc" | "desc" | undefined;
56
+ }, {
57
+ orderBy?: "updatedAt" | undefined;
58
+ cursor?: string | undefined;
59
+ first?: string | undefined;
60
+ last?: string | undefined;
61
+ order?: "asc" | "desc" | undefined;
62
+ }>;
63
+ };
64
+ responses: {
65
+ 200: {
66
+ content: {
67
+ 'application/json': {
68
+ schema: import("zod").ZodObject<{
69
+ edges: import("zod").ZodArray<import("zod").ZodObject<{
70
+ id: import("zod").ZodNumber;
71
+ title: import("zod").ZodString;
72
+ createdAt: import("zod").ZodDate;
73
+ updatedAt: import("zod").ZodDate;
74
+ }, "strip", import("zod").ZodTypeAny, {
75
+ id: number;
76
+ title: string;
77
+ createdAt: Date;
78
+ updatedAt: Date;
79
+ }, {
80
+ id: number;
81
+ title: string;
82
+ createdAt: Date;
83
+ updatedAt: Date;
84
+ }>, "many">;
85
+ pageInfo: import("zod").ZodObject<{
86
+ totalCount: import("zod").ZodNumber;
87
+ count: import("zod").ZodNumber;
88
+ hasNextPage: import("zod").ZodBoolean;
89
+ hasPreviousPage: import("zod").ZodBoolean;
90
+ startCursor: import("zod").ZodNullable<import("zod").ZodNumber>;
91
+ endCursor: import("zod").ZodNullable<import("zod").ZodNumber>;
92
+ }, "strip", import("zod").ZodTypeAny, {
93
+ count: number;
94
+ totalCount: number;
95
+ hasNextPage: boolean;
96
+ hasPreviousPage: boolean;
97
+ startCursor: number | null;
98
+ endCursor: number | null;
99
+ }, {
100
+ count: number;
101
+ totalCount: number;
102
+ hasNextPage: boolean;
103
+ hasPreviousPage: boolean;
104
+ startCursor: number | null;
105
+ endCursor: number | null;
106
+ }>;
107
+ }, "strip", import("zod").ZodTypeAny, {
108
+ edges: {
109
+ id: number;
110
+ title: string;
111
+ createdAt: Date;
112
+ updatedAt: Date;
113
+ }[];
114
+ pageInfo: {
115
+ count: number;
116
+ totalCount: number;
117
+ hasNextPage: boolean;
118
+ hasPreviousPage: boolean;
119
+ startCursor: number | null;
120
+ endCursor: number | null;
121
+ };
122
+ }, {
123
+ edges: {
124
+ id: number;
125
+ title: string;
126
+ createdAt: Date;
127
+ updatedAt: Date;
128
+ }[];
129
+ pageInfo: {
130
+ count: number;
131
+ totalCount: number;
132
+ hasNextPage: boolean;
133
+ hasPreviousPage: boolean;
134
+ startCursor: number | null;
135
+ endCursor: number | null;
136
+ };
137
+ }>;
138
+ };
139
+ };
140
+ description: string;
141
+ };
142
+ };
143
+ } & {
144
+ getRoutingPath: () => "/";
145
+ };
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
+ }], 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
+ //# sourceMappingURL=categories.module.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1 @@
1
+ import{buildModule}from"@vitnode/core/api/lib/module";import{CONFIG_PLUGIN}from"../../../config.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]});
@@ -0,0 +1,79 @@
1
+ import { z } from '@hono/zod-openapi';
2
+ export declare const zodCreateCategorySchema: z.ZodObject<{
3
+ title: z.ZodString;
4
+ }, "strip", z.ZodTypeAny, {
5
+ title: string;
6
+ }, {
7
+ title: string;
8
+ }>;
9
+ export declare const createCategoryRoute: {
10
+ handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global/global").EnvVitNode, "/", {
11
+ in: {
12
+ json: {
13
+ title: string;
14
+ };
15
+ };
16
+ out: {
17
+ json: {
18
+ title: string;
19
+ };
20
+ };
21
+ }>) => Promise<Response & import("hono").TypedResponse<{
22
+ id: number;
23
+ title: string;
24
+ createdAt: string;
25
+ updatedAt: string;
26
+ titleSeo: string;
27
+ }, 201, "json">>;
28
+ pluginId: "@vitnode/blog";
29
+ route: {
30
+ method: "post";
31
+ path: "/";
32
+ request: {
33
+ body: {
34
+ content: {
35
+ 'application/json': {
36
+ schema: z.ZodObject<{
37
+ title: z.ZodString;
38
+ }, "strip", z.ZodTypeAny, {
39
+ title: string;
40
+ }, {
41
+ title: string;
42
+ }>;
43
+ };
44
+ };
45
+ };
46
+ };
47
+ responses: {
48
+ 201: {
49
+ content: {
50
+ 'application/json': {
51
+ schema: z.ZodObject<{
52
+ id: z.ZodNumber;
53
+ title: z.ZodString;
54
+ createdAt: z.ZodDate;
55
+ updatedAt: z.ZodDate;
56
+ }, "strip", z.ZodTypeAny, {
57
+ id: number;
58
+ title: string;
59
+ createdAt: Date;
60
+ updatedAt: Date;
61
+ }, {
62
+ id: number;
63
+ title: string;
64
+ createdAt: Date;
65
+ updatedAt: Date;
66
+ }>;
67
+ };
68
+ };
69
+ description: string;
70
+ };
71
+ 400: {
72
+ description: string;
73
+ };
74
+ };
75
+ } & {
76
+ getRoutingPath: () => "/";
77
+ };
78
+ };
79
+ //# sourceMappingURL=create.route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.route.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/categories/routes/create.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAStC,eAAO,MAAM,uBAAuB;;;;;;EAKlC,CAAC;AASH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyD9B,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"../../../../config.js";import{blog_categories}from"../../../../database/categories.js";export const zodCreateCategorySchema=z.object({title:z.string().min(3,"Title must be at least 3 characters long").max(100,"Title must not exceed 100 characters")});const zodCategoryResponseSchema=z.object({id:z.number(),title:z.string(),createdAt:z.date(),updatedAt:z.date()});export const createCategoryRoute=buildRoute({...CONFIG_PLUGIN,route:{method:"post",path:"/",request:{body:{content:{"application/json":{schema:zodCreateCategorySchema}}}},responses:{201:{content:{"application/json":{schema:zodCategoryResponseSchema}},description:"Category created successfully"},400:{description:"Bad request - Invalid input data"}}},handler:async c=>{const{title}=c.req.valid("json");const titleSeo=removeSpecialCharacters(title);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){throw new HTTPException(400,{message:"Category with this title already exists."})}const[category]=await c.get("db").insert(blog_categories).values({title,titleSeo:removeSpecialCharacters(title)}).returning();return c.json(category,201)}});
@@ -0,0 +1,40 @@
1
+ import { z } from '@hono/zod-openapi';
2
+ export declare const deleteCategoryRoute: {
3
+ handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global/global").EnvVitNode, "/:id", {
4
+ in: {
5
+ param: {
6
+ id: string;
7
+ };
8
+ };
9
+ out: {
10
+ param: {
11
+ id: number;
12
+ };
13
+ };
14
+ }>) => Promise<Response & import("hono").TypedResponse<null, 204, "body">>;
15
+ pluginId: "@vitnode/blog";
16
+ route: {
17
+ method: "delete";
18
+ path: "/{id}";
19
+ request: {
20
+ params: z.ZodObject<{
21
+ id: z.ZodEffects<z.ZodString, number, string>;
22
+ }, "strip", z.ZodTypeAny, {
23
+ id: number;
24
+ }, {
25
+ id: string;
26
+ }>;
27
+ };
28
+ responses: {
29
+ 204: {
30
+ description: string;
31
+ };
32
+ 404: {
33
+ description: string;
34
+ };
35
+ };
36
+ } & {
37
+ getRoutingPath: () => "/:id";
38
+ };
39
+ };
40
+ //# sourceMappingURL=delete.route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.route.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/categories/routes/delete.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAQtC,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkC9B,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"../../../../config.js";import{blog_categories}from"../../../../database/categories.js";export const deleteCategoryRoute=buildRoute({...CONFIG_PLUGIN,route:{method:"delete",path:"/{id}",request:{params:z.object({id:z.string().transform(Number)})},responses:{204:{description:"Category deleted successfully"},404:{description:"Category not found"}}},handler:async c=>{const{id}=c.req.valid("param");const result=await c.get("db").delete(blog_categories).where(eq(blog_categories.id,id)).returning();if(result.length===0){throw new HTTPException(404)}return c.body(null,204)}});
@@ -0,0 +1,100 @@
1
+ import { z } from '@hono/zod-openapi';
2
+ export declare const zodEditCategorySchema: z.ZodObject<{
3
+ title: z.ZodString;
4
+ }, "strip", z.ZodTypeAny, {
5
+ title: string;
6
+ }, {
7
+ title: string;
8
+ }>;
9
+ export declare const editCategoryRoute: {
10
+ handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global/global").EnvVitNode, "/:id", {
11
+ in: {
12
+ param: {
13
+ id: string;
14
+ };
15
+ };
16
+ out: {
17
+ param: {
18
+ id: number;
19
+ };
20
+ };
21
+ } & {
22
+ in: {
23
+ json: {
24
+ title: string;
25
+ };
26
+ };
27
+ out: {
28
+ json: {
29
+ title: string;
30
+ };
31
+ };
32
+ }>) => Promise<Response & import("hono").TypedResponse<{
33
+ id: number;
34
+ title: string;
35
+ createdAt: string;
36
+ updatedAt: string;
37
+ titleSeo: string;
38
+ }, 400 | 200 | 404, "json">>;
39
+ pluginId: "@vitnode/blog";
40
+ route: {
41
+ method: "put";
42
+ path: "/{id}";
43
+ request: {
44
+ params: z.ZodObject<{
45
+ id: z.ZodEffects<z.ZodString, number, string>;
46
+ }, "strip", z.ZodTypeAny, {
47
+ id: number;
48
+ }, {
49
+ id: string;
50
+ }>;
51
+ body: {
52
+ content: {
53
+ 'application/json': {
54
+ schema: z.ZodObject<{
55
+ title: z.ZodString;
56
+ }, "strip", z.ZodTypeAny, {
57
+ title: string;
58
+ }, {
59
+ title: string;
60
+ }>;
61
+ };
62
+ };
63
+ };
64
+ };
65
+ responses: {
66
+ 200: {
67
+ content: {
68
+ 'application/json': {
69
+ schema: z.ZodObject<{
70
+ id: z.ZodNumber;
71
+ title: z.ZodString;
72
+ createdAt: z.ZodDate;
73
+ updatedAt: z.ZodDate;
74
+ }, "strip", z.ZodTypeAny, {
75
+ id: number;
76
+ title: string;
77
+ createdAt: Date;
78
+ updatedAt: Date;
79
+ }, {
80
+ id: number;
81
+ title: string;
82
+ createdAt: Date;
83
+ updatedAt: Date;
84
+ }>;
85
+ };
86
+ };
87
+ description: string;
88
+ };
89
+ 400: {
90
+ description: string;
91
+ };
92
+ 404: {
93
+ description: string;
94
+ };
95
+ };
96
+ } & {
97
+ getRoutingPath: () => "/:id";
98
+ };
99
+ };
100
+ //# sourceMappingURL=edit.route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit.route.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/categories/routes/edit.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAStC,eAAO,MAAM,qBAAqB;;;;;;EAKhC,CAAC;AASH,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"../../../../config.js";import{blog_categories}from"../../../../database/categories.js";export const zodEditCategorySchema=z.object({title:z.string().min(3,"Title must be at least 3 characters long").max(100,"Title must not exceed 100 characters")});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:zodEditCategorySchema}}}},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)}});