@vitnode/blog 1.2.0-canary.16 → 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.
- package/dist/src/api/modules/categories/categories.module.d.ts +343 -0
- package/dist/src/api/modules/categories/categories.module.d.ts.map +1 -0
- package/dist/src/api/modules/categories/categories.module.js +1 -0
- package/dist/src/api/modules/categories/routes/create.route.d.ts +79 -0
- package/dist/src/api/modules/categories/routes/create.route.d.ts.map +1 -0
- package/dist/src/api/modules/categories/routes/create.route.js +1 -0
- package/dist/src/api/modules/categories/routes/delete.route.d.ts +40 -0
- package/dist/src/api/modules/categories/routes/delete.route.d.ts.map +1 -0
- package/dist/src/api/modules/categories/routes/delete.route.js +1 -0
- package/dist/src/api/modules/categories/routes/edit.route.d.ts +100 -0
- package/dist/src/api/modules/categories/routes/edit.route.d.ts.map +1 -0
- package/dist/src/api/modules/categories/routes/edit.route.js +1 -0
- package/dist/src/api/modules/categories/routes/get.route.d.ts +148 -0
- package/dist/src/api/modules/categories/routes/get.route.d.ts.map +1 -0
- package/dist/src/api/modules/categories/routes/get.route.js +1 -0
- package/dist/src/api/modules/posts/posts.module.d.ts +448 -0
- package/dist/src/api/modules/posts/posts.module.d.ts.map +1 -0
- package/dist/src/api/modules/posts/posts.module.js +1 -0
- package/dist/src/api/modules/posts/routes/create.route.d.ts +109 -0
- package/dist/src/api/modules/posts/routes/create.route.d.ts.map +1 -0
- package/dist/src/api/modules/posts/routes/create.route.js +1 -0
- package/dist/src/api/modules/posts/routes/delete.route.d.ts +40 -0
- package/dist/src/api/modules/posts/routes/delete.route.d.ts.map +1 -0
- package/dist/src/api/modules/posts/routes/delete.route.js +1 -0
- package/dist/src/api/modules/posts/routes/edit.route.d.ts +127 -0
- package/dist/src/api/modules/posts/routes/edit.route.d.ts.map +1 -0
- package/dist/src/api/modules/posts/routes/edit.route.js +1 -0
- package/dist/src/api/modules/posts/routes/get.route.d.ts +208 -0
- package/dist/src/api/modules/posts/routes/get.route.d.ts.map +1 -0
- package/dist/src/api/modules/posts/routes/get.route.js +1 -0
- package/dist/src/app_admin/blog/categories/page.d.ts +5 -0
- package/dist/src/app_admin/blog/categories/page.d.ts.map +1 -0
- package/dist/src/app_admin/blog/categories/page.js +1 -0
- package/dist/src/config.api.d.ts +2 -0
- package/dist/src/config.api.d.ts.map +1 -0
- package/dist/src/config.api.js +1 -0
- package/dist/src/config.d.ts +4 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +1 -0
- package/dist/src/database/categories.d.ts +97 -0
- package/dist/src/database/categories.d.ts.map +1 -0
- package/dist/src/database/categories.js +1 -0
- package/{src/database/index.ts → dist/src/database/index.d.ts} +1 -3
- package/dist/src/database/index.d.ts.map +1 -0
- package/dist/src/database/index.js +1 -0
- package/dist/src/database/posts.d.ts +131 -0
- package/dist/src/database/posts.d.ts.map +1 -0
- package/dist/src/database/posts.js +1 -0
- package/dist/src/database/relations.d.ts +7 -0
- package/dist/src/database/relations.d.ts.map +1 -0
- package/dist/src/database/relations.js +1 -0
- package/dist/src/plugin.d.ts +2 -0
- package/dist/src/plugin.d.ts.map +1 -0
- package/dist/src/plugin.js +1 -0
- package/dist/src/views/admin/categories/actions/actions.d.ts +2 -0
- package/dist/src/views/admin/categories/actions/actions.d.ts.map +1 -0
- package/dist/src/views/admin/categories/actions/actions.js +1 -0
- package/dist/src/views/admin/categories/actions/create-edit/create-edit.d.ts +8 -0
- package/dist/src/views/admin/categories/actions/create-edit/create-edit.d.ts.map +1 -0
- package/dist/src/views/admin/categories/actions/create-edit/create-edit.js +1 -0
- package/dist/src/views/admin/categories/actions/create-edit/mutation-api.d.ts +11 -0
- package/dist/src/views/admin/categories/actions/create-edit/mutation-api.d.ts.map +1 -0
- package/dist/src/views/admin/categories/actions/create-edit/mutation-api.js +1 -0
- package/dist/src/views/admin/categories/categories-admin-view.d.ts +4 -0
- package/dist/src/views/admin/categories/categories-admin-view.d.ts.map +1 -0
- package/dist/src/views/admin/categories/categories-admin-view.js +1 -0
- package/dist/src/views/admin/categories/row-actions/delete/delete-action.d.ts +5 -0
- package/dist/src/views/admin/categories/row-actions/delete/delete-action.d.ts.map +1 -0
- package/dist/src/views/admin/categories/row-actions/delete/delete-action.js +1 -0
- package/dist/src/views/admin/categories/row-actions/delete/mutation-api.d.ts +4 -0
- package/dist/src/views/admin/categories/row-actions/delete/mutation-api.d.ts.map +1 -0
- package/dist/src/views/admin/categories/row-actions/delete/mutation-api.js +1 -0
- package/dist/src/views/admin/categories/row-actions/edit-action.d.ts +9 -0
- package/dist/src/views/admin/categories/row-actions/edit-action.d.ts.map +1 -0
- package/dist/src/views/admin/categories/row-actions/edit-action.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +3 -3
- package/src/database/categories.ts +0 -12
- package/src/database/posts.ts +0 -19
- package/src/database/relations.ts +0 -18
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { z } from '@hono/zod-openapi';
|
|
2
|
+
export declare const zodCreatePostSchema: z.ZodObject<{
|
|
3
|
+
title: z.ZodString;
|
|
4
|
+
content: z.ZodString;
|
|
5
|
+
categoryId: z.ZodNumber;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
title: string;
|
|
8
|
+
content: string;
|
|
9
|
+
categoryId: number;
|
|
10
|
+
}, {
|
|
11
|
+
title: string;
|
|
12
|
+
content: string;
|
|
13
|
+
categoryId: number;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const createPostRoute: {
|
|
16
|
+
handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global/global").EnvVitNode, "/", {
|
|
17
|
+
in: {
|
|
18
|
+
json: {
|
|
19
|
+
title: string;
|
|
20
|
+
content: string;
|
|
21
|
+
categoryId: number;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
out: {
|
|
25
|
+
json: {
|
|
26
|
+
title: string;
|
|
27
|
+
content: string;
|
|
28
|
+
categoryId: number;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
}>) => Promise<Response & import("hono").TypedResponse<{
|
|
32
|
+
id: number;
|
|
33
|
+
title: string;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
updatedAt: string;
|
|
36
|
+
titleSeo: string;
|
|
37
|
+
content: string;
|
|
38
|
+
categoryId: number;
|
|
39
|
+
}, 201, "json">>;
|
|
40
|
+
pluginId: "@vitnode/blog";
|
|
41
|
+
route: {
|
|
42
|
+
method: "post";
|
|
43
|
+
path: "/";
|
|
44
|
+
request: {
|
|
45
|
+
body: {
|
|
46
|
+
content: {
|
|
47
|
+
'application/json': {
|
|
48
|
+
schema: z.ZodObject<{
|
|
49
|
+
title: z.ZodString;
|
|
50
|
+
content: z.ZodString;
|
|
51
|
+
categoryId: z.ZodNumber;
|
|
52
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
|
+
title: string;
|
|
54
|
+
content: string;
|
|
55
|
+
categoryId: number;
|
|
56
|
+
}, {
|
|
57
|
+
title: string;
|
|
58
|
+
content: string;
|
|
59
|
+
categoryId: number;
|
|
60
|
+
}>;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
responses: {
|
|
66
|
+
201: {
|
|
67
|
+
content: {
|
|
68
|
+
'application/json': {
|
|
69
|
+
schema: z.ZodObject<{
|
|
70
|
+
id: z.ZodNumber;
|
|
71
|
+
title: z.ZodString;
|
|
72
|
+
titleSeo: z.ZodString;
|
|
73
|
+
content: z.ZodString;
|
|
74
|
+
categoryId: z.ZodNumber;
|
|
75
|
+
createdAt: z.ZodDate;
|
|
76
|
+
updatedAt: z.ZodDate;
|
|
77
|
+
}, "strip", z.ZodTypeAny, {
|
|
78
|
+
id: number;
|
|
79
|
+
title: string;
|
|
80
|
+
createdAt: Date;
|
|
81
|
+
updatedAt: Date;
|
|
82
|
+
titleSeo: string;
|
|
83
|
+
content: string;
|
|
84
|
+
categoryId: number;
|
|
85
|
+
}, {
|
|
86
|
+
id: number;
|
|
87
|
+
title: string;
|
|
88
|
+
createdAt: Date;
|
|
89
|
+
updatedAt: Date;
|
|
90
|
+
titleSeo: string;
|
|
91
|
+
content: string;
|
|
92
|
+
categoryId: number;
|
|
93
|
+
}>;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
description: string;
|
|
97
|
+
};
|
|
98
|
+
400: {
|
|
99
|
+
description: string;
|
|
100
|
+
};
|
|
101
|
+
404: {
|
|
102
|
+
description: string;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
} & {
|
|
106
|
+
getRoutingPath: () => "/";
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=create.route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.route.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/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"../../../../config.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().min(10,"Content must be at least 10 characters long"),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)}});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from '@hono/zod-openapi';
|
|
2
|
+
export declare const deletePostRoute: {
|
|
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/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"../../../../config.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)}});
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { z } from '@hono/zod-openapi';
|
|
2
|
+
export declare const zodEditPostSchema: z.ZodObject<{
|
|
3
|
+
title: z.ZodString;
|
|
4
|
+
content: z.ZodString;
|
|
5
|
+
categoryId: z.ZodNumber;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
title: string;
|
|
8
|
+
content: string;
|
|
9
|
+
categoryId: number;
|
|
10
|
+
}, {
|
|
11
|
+
title: string;
|
|
12
|
+
content: string;
|
|
13
|
+
categoryId: number;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const editPostRoute: {
|
|
16
|
+
handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global/global").EnvVitNode, "/:id", {
|
|
17
|
+
in: {
|
|
18
|
+
param: {
|
|
19
|
+
id: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
out: {
|
|
23
|
+
param: {
|
|
24
|
+
id: number;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
} & {
|
|
28
|
+
in: {
|
|
29
|
+
json: {
|
|
30
|
+
title: string;
|
|
31
|
+
content: string;
|
|
32
|
+
categoryId: number;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
out: {
|
|
36
|
+
json: {
|
|
37
|
+
title: string;
|
|
38
|
+
content: string;
|
|
39
|
+
categoryId: number;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
}>) => Promise<Response & import("hono").TypedResponse<{
|
|
43
|
+
id: number;
|
|
44
|
+
title: string;
|
|
45
|
+
titleSeo: string;
|
|
46
|
+
content: string;
|
|
47
|
+
categoryId: number;
|
|
48
|
+
createdAt: string;
|
|
49
|
+
updatedAt: string;
|
|
50
|
+
}, 400 | 200 | 404, "json">>;
|
|
51
|
+
pluginId: "@vitnode/blog";
|
|
52
|
+
route: {
|
|
53
|
+
method: "put";
|
|
54
|
+
path: "/{id}";
|
|
55
|
+
request: {
|
|
56
|
+
params: z.ZodObject<{
|
|
57
|
+
id: z.ZodEffects<z.ZodString, number, string>;
|
|
58
|
+
}, "strip", z.ZodTypeAny, {
|
|
59
|
+
id: number;
|
|
60
|
+
}, {
|
|
61
|
+
id: string;
|
|
62
|
+
}>;
|
|
63
|
+
body: {
|
|
64
|
+
content: {
|
|
65
|
+
'application/json': {
|
|
66
|
+
schema: z.ZodObject<{
|
|
67
|
+
title: z.ZodString;
|
|
68
|
+
content: z.ZodString;
|
|
69
|
+
categoryId: z.ZodNumber;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
title: string;
|
|
72
|
+
content: string;
|
|
73
|
+
categoryId: number;
|
|
74
|
+
}, {
|
|
75
|
+
title: string;
|
|
76
|
+
content: string;
|
|
77
|
+
categoryId: number;
|
|
78
|
+
}>;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
responses: {
|
|
84
|
+
200: {
|
|
85
|
+
content: {
|
|
86
|
+
'application/json': {
|
|
87
|
+
schema: z.ZodObject<{
|
|
88
|
+
id: z.ZodNumber;
|
|
89
|
+
title: z.ZodString;
|
|
90
|
+
titleSeo: z.ZodString;
|
|
91
|
+
content: z.ZodString;
|
|
92
|
+
categoryId: z.ZodNumber;
|
|
93
|
+
createdAt: z.ZodDate;
|
|
94
|
+
updatedAt: z.ZodDate;
|
|
95
|
+
}, "strip", z.ZodTypeAny, {
|
|
96
|
+
id: number;
|
|
97
|
+
title: string;
|
|
98
|
+
createdAt: Date;
|
|
99
|
+
updatedAt: Date;
|
|
100
|
+
titleSeo: string;
|
|
101
|
+
content: string;
|
|
102
|
+
categoryId: number;
|
|
103
|
+
}, {
|
|
104
|
+
id: number;
|
|
105
|
+
title: string;
|
|
106
|
+
createdAt: Date;
|
|
107
|
+
updatedAt: Date;
|
|
108
|
+
titleSeo: string;
|
|
109
|
+
content: string;
|
|
110
|
+
categoryId: number;
|
|
111
|
+
}>;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
description: string;
|
|
115
|
+
};
|
|
116
|
+
400: {
|
|
117
|
+
description: string;
|
|
118
|
+
};
|
|
119
|
+
404: {
|
|
120
|
+
description: string;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
} & {
|
|
124
|
+
getRoutingPath: () => "/:id";
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=edit.route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit.route.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/posts/routes/edit.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAUtC,eAAO,MAAM,iBAAiB;;;;;;;;;;;;EAO5B,CAAC;AAYH,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"../../../../config.js";import{blog_categories}from"../../../../database/categories.js";import{blog_posts}from"../../../../database/posts.js";export const zodEditPostSchema=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().min(10,"Content must be at least 10 characters long"),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 editPostRoute=buildRoute({...CONFIG_PLUGIN,route:{method:"put",path:"/{id}",request:{params:z.object({id:z.string().transform(Number)}),body:{content:{"application/json":{schema:zodEditPostSchema}}}},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)}});
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { z } from '@hono/zod-openapi';
|
|
2
|
+
export declare const postsRoute: {
|
|
3
|
+
handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global/global").EnvVitNode, "/", {
|
|
4
|
+
in: {
|
|
5
|
+
query: {
|
|
6
|
+
orderBy?: "createdAt" | "updatedAt" | undefined;
|
|
7
|
+
cursor?: string | undefined;
|
|
8
|
+
first?: string | undefined;
|
|
9
|
+
last?: string | undefined;
|
|
10
|
+
order?: "asc" | "desc" | undefined;
|
|
11
|
+
categoryId?: string | undefined;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
out: {
|
|
15
|
+
query: {
|
|
16
|
+
orderBy?: "createdAt" | "updatedAt" | undefined;
|
|
17
|
+
cursor?: string | undefined;
|
|
18
|
+
first?: string | undefined;
|
|
19
|
+
last?: string | undefined;
|
|
20
|
+
order?: "asc" | "desc" | undefined;
|
|
21
|
+
categoryId?: number | undefined;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
}>) => Promise<Response & import("hono").TypedResponse<{
|
|
25
|
+
edges: {
|
|
26
|
+
id: number;
|
|
27
|
+
title: string;
|
|
28
|
+
titleSeo: string;
|
|
29
|
+
content: string;
|
|
30
|
+
categoryId: number;
|
|
31
|
+
createdAt: string;
|
|
32
|
+
updatedAt: string;
|
|
33
|
+
category: {
|
|
34
|
+
id: number;
|
|
35
|
+
title: string;
|
|
36
|
+
titleSeo: string;
|
|
37
|
+
};
|
|
38
|
+
}[];
|
|
39
|
+
pageInfo: {
|
|
40
|
+
count: number;
|
|
41
|
+
endCursor: null | number;
|
|
42
|
+
hasNextPage: boolean;
|
|
43
|
+
hasPreviousPage: boolean;
|
|
44
|
+
startCursor: null | number;
|
|
45
|
+
totalCount: number;
|
|
46
|
+
};
|
|
47
|
+
}, 200, "json">>;
|
|
48
|
+
pluginId: "@vitnode/blog";
|
|
49
|
+
route: {
|
|
50
|
+
method: "get";
|
|
51
|
+
path: "/";
|
|
52
|
+
request: {
|
|
53
|
+
query: z.ZodObject<{
|
|
54
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
55
|
+
first: z.ZodOptional<z.ZodString>;
|
|
56
|
+
last: z.ZodOptional<z.ZodString>;
|
|
57
|
+
} & {
|
|
58
|
+
order: z.ZodOptional<z.ZodEnum<["asc", "desc"]>>;
|
|
59
|
+
orderBy: z.ZodOptional<z.ZodEnum<["updatedAt", "createdAt"]>>;
|
|
60
|
+
categoryId: z.ZodOptional<z.ZodEffects<z.ZodString, number, string>>;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
orderBy?: "createdAt" | "updatedAt" | undefined;
|
|
63
|
+
cursor?: string | undefined;
|
|
64
|
+
first?: string | undefined;
|
|
65
|
+
last?: string | undefined;
|
|
66
|
+
order?: "asc" | "desc" | undefined;
|
|
67
|
+
categoryId?: number | undefined;
|
|
68
|
+
}, {
|
|
69
|
+
orderBy?: "createdAt" | "updatedAt" | undefined;
|
|
70
|
+
cursor?: string | undefined;
|
|
71
|
+
first?: string | undefined;
|
|
72
|
+
last?: string | undefined;
|
|
73
|
+
order?: "asc" | "desc" | undefined;
|
|
74
|
+
categoryId?: string | undefined;
|
|
75
|
+
}>;
|
|
76
|
+
};
|
|
77
|
+
responses: {
|
|
78
|
+
200: {
|
|
79
|
+
content: {
|
|
80
|
+
'application/json': {
|
|
81
|
+
schema: z.ZodObject<{
|
|
82
|
+
edges: z.ZodArray<z.ZodObject<{
|
|
83
|
+
id: z.ZodNumber;
|
|
84
|
+
title: z.ZodString;
|
|
85
|
+
titleSeo: z.ZodString;
|
|
86
|
+
content: z.ZodString;
|
|
87
|
+
categoryId: z.ZodNumber;
|
|
88
|
+
createdAt: z.ZodDate;
|
|
89
|
+
updatedAt: z.ZodDate;
|
|
90
|
+
category: z.ZodObject<{
|
|
91
|
+
id: z.ZodNumber;
|
|
92
|
+
title: z.ZodString;
|
|
93
|
+
titleSeo: z.ZodString;
|
|
94
|
+
}, "strip", z.ZodTypeAny, {
|
|
95
|
+
id: number;
|
|
96
|
+
title: string;
|
|
97
|
+
titleSeo: string;
|
|
98
|
+
}, {
|
|
99
|
+
id: number;
|
|
100
|
+
title: string;
|
|
101
|
+
titleSeo: string;
|
|
102
|
+
}>;
|
|
103
|
+
}, "strip", z.ZodTypeAny, {
|
|
104
|
+
id: number;
|
|
105
|
+
title: string;
|
|
106
|
+
createdAt: Date;
|
|
107
|
+
updatedAt: Date;
|
|
108
|
+
titleSeo: string;
|
|
109
|
+
content: string;
|
|
110
|
+
category: {
|
|
111
|
+
id: number;
|
|
112
|
+
title: string;
|
|
113
|
+
titleSeo: string;
|
|
114
|
+
};
|
|
115
|
+
categoryId: number;
|
|
116
|
+
}, {
|
|
117
|
+
id: number;
|
|
118
|
+
title: string;
|
|
119
|
+
createdAt: Date;
|
|
120
|
+
updatedAt: Date;
|
|
121
|
+
titleSeo: string;
|
|
122
|
+
content: string;
|
|
123
|
+
category: {
|
|
124
|
+
id: number;
|
|
125
|
+
title: string;
|
|
126
|
+
titleSeo: string;
|
|
127
|
+
};
|
|
128
|
+
categoryId: number;
|
|
129
|
+
}>, "many">;
|
|
130
|
+
pageInfo: z.ZodObject<{
|
|
131
|
+
totalCount: z.ZodNumber;
|
|
132
|
+
count: z.ZodNumber;
|
|
133
|
+
hasNextPage: z.ZodBoolean;
|
|
134
|
+
hasPreviousPage: z.ZodBoolean;
|
|
135
|
+
startCursor: z.ZodNullable<z.ZodNumber>;
|
|
136
|
+
endCursor: z.ZodNullable<z.ZodNumber>;
|
|
137
|
+
}, "strip", z.ZodTypeAny, {
|
|
138
|
+
count: number;
|
|
139
|
+
totalCount: number;
|
|
140
|
+
hasNextPage: boolean;
|
|
141
|
+
hasPreviousPage: boolean;
|
|
142
|
+
startCursor: number | null;
|
|
143
|
+
endCursor: number | null;
|
|
144
|
+
}, {
|
|
145
|
+
count: number;
|
|
146
|
+
totalCount: number;
|
|
147
|
+
hasNextPage: boolean;
|
|
148
|
+
hasPreviousPage: boolean;
|
|
149
|
+
startCursor: number | null;
|
|
150
|
+
endCursor: number | null;
|
|
151
|
+
}>;
|
|
152
|
+
}, "strip", z.ZodTypeAny, {
|
|
153
|
+
edges: {
|
|
154
|
+
id: number;
|
|
155
|
+
title: string;
|
|
156
|
+
createdAt: Date;
|
|
157
|
+
updatedAt: Date;
|
|
158
|
+
titleSeo: string;
|
|
159
|
+
content: string;
|
|
160
|
+
category: {
|
|
161
|
+
id: number;
|
|
162
|
+
title: string;
|
|
163
|
+
titleSeo: string;
|
|
164
|
+
};
|
|
165
|
+
categoryId: number;
|
|
166
|
+
}[];
|
|
167
|
+
pageInfo: {
|
|
168
|
+
count: number;
|
|
169
|
+
totalCount: number;
|
|
170
|
+
hasNextPage: boolean;
|
|
171
|
+
hasPreviousPage: boolean;
|
|
172
|
+
startCursor: number | null;
|
|
173
|
+
endCursor: number | null;
|
|
174
|
+
};
|
|
175
|
+
}, {
|
|
176
|
+
edges: {
|
|
177
|
+
id: number;
|
|
178
|
+
title: string;
|
|
179
|
+
createdAt: Date;
|
|
180
|
+
updatedAt: Date;
|
|
181
|
+
titleSeo: string;
|
|
182
|
+
content: string;
|
|
183
|
+
category: {
|
|
184
|
+
id: number;
|
|
185
|
+
title: string;
|
|
186
|
+
titleSeo: string;
|
|
187
|
+
};
|
|
188
|
+
categoryId: number;
|
|
189
|
+
}[];
|
|
190
|
+
pageInfo: {
|
|
191
|
+
count: number;
|
|
192
|
+
totalCount: number;
|
|
193
|
+
hasNextPage: boolean;
|
|
194
|
+
hasPreviousPage: boolean;
|
|
195
|
+
startCursor: number | null;
|
|
196
|
+
endCursor: number | null;
|
|
197
|
+
};
|
|
198
|
+
}>;
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
description: string;
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
} & {
|
|
205
|
+
getRoutingPath: () => "/";
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
//# sourceMappingURL=get.route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.route.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/posts/routes/get.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AA4BtC,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2ErB,CAAC"}
|
|
@@ -0,0 +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{eq}from"drizzle-orm";import{CONFIG_PLUGIN}from"../../../../config.js";import{blog_categories}from"../../../../database/categories.js";import{blog_posts}from"../../../../database/posts.js";const zodPostSchema=z.object({id:z.number(),title:z.string(),titleSeo:z.string(),content:z.string(),categoryId:z.number(),createdAt:z.date(),updatedAt:z.date(),category:z.object({id:z.number(),title:z.string(),titleSeo:z.string()})});export const postsRoute=buildRoute({...CONFIG_PLUGIN,route:{method:"get",path:"/",request:{query:zodPaginationQuery.extend({order:z.enum(["asc","desc"]).optional(),orderBy:z.enum(["updatedAt","createdAt"]).optional(),categoryId:z.string().transform(Number).optional()})},responses:{200:{content:{"application/json":{schema:z.object({edges:z.array(zodPostSchema),pageInfo:zodPaginationPageInfo})}},description:"Posts retrieved successfully"}}},handler:async c=>{const query=c.req.valid("query");const data=await withPagination({c,params:{query},primaryCursor:blog_posts.id,query:async({limit,where,orderBy})=>await c.get("db").select({id:blog_posts.id,title:blog_posts.title,titleSeo:blog_posts.titleSeo,content:blog_posts.content,categoryId:blog_posts.categoryId,createdAt:blog_posts.createdAt,updatedAt:blog_posts.updatedAt,category:{id:blog_categories.id,title:blog_categories.title,titleSeo:blog_categories.titleSeo}}).from(blog_posts).innerJoin(blog_categories,eq(blog_posts.categoryId,blog_categories.id)).where(query.categoryId?eq(blog_posts.categoryId,query.categoryId):where).orderBy(orderBy).limit(limit),table:blog_posts,orderBy:{column:query.orderBy?blog_posts[query.orderBy]:blog_posts.updatedAt,order:query.order??"desc"}});return c.json(data)}});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Metadata } from 'next';
|
|
2
|
+
import { CategoriesAdminView } from '../../../views/admin/categories/categories-admin-view';
|
|
3
|
+
export declare const generateMetadata: () => Promise<Metadata>;
|
|
4
|
+
export default function CategoriesPage(params: React.ComponentProps<typeof CategoriesAdminView>): Promise<import("react/jsx-runtime").JSX.Element>;
|
|
5
|
+
//# sourceMappingURL=page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../../../src/app_admin/blog/categories/page.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAMrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAC;AAIrF,eAAO,MAAM,gBAAgB,QAAa,OAAO,CAAC,QAAQ,CAMzD,CAAC;AAEF,wBAA8B,cAAc,CAC1C,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,mBAAmB,CAAC,oDAkBzD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{I18nProvider}from"@vitnode/core/components/i18n-provider";import{HeaderContent}from"@vitnode/core/components/ui/header-content";import{getTranslations}from"next-intl/server";import{CategoriesAdminView}from"../../../views/admin/categories/categories-admin-view.js";import{ActionsCategoriesAdmin}from"../../../views/admin/categories/actions/actions.js";export const generateMetadata=async()=>{const t=await getTranslations("@vitnode/blog.admin.nav");return{title:t("categories")}};export default async function CategoriesPage(params){const[t,tNav]=await Promise.all([getTranslations("@vitnode/blog.admin.categories"),getTranslations("@vitnode/blog.admin.nav")]);return _jsx(I18nProvider,{namespaces:["@vitnode/blog.admin.categories"],children:_jsxs("div",{className:"container mx-auto p-4",children:[_jsx(HeaderContent,{desc:t("desc"),h1:tNav("categories"),children:_jsx(ActionsCategoriesAdmin,{})}),_jsx(CategoriesAdminView,{...params})]})})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.api.d.ts","sourceRoot":"","sources":["../../src/config.api.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,aAAa,mEAKzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{buildApiPlugin}from"@vitnode/core/api/lib/plugin";import{CONFIG_PLUGIN}from"./config.js";import{categoriesModule}from"./api/modules/categories/categories.module.js";import{postsModule}from"./api/modules/posts/posts.module.js";export const blogApiPlugin=()=>{return buildApiPlugin({...CONFIG_PLUGIN,modules:[categoriesModule,postsModule]})};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;CAEzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const CONFIG_PLUGIN={pluginId:"@vitnode/blog"};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export declare const blog_categories: Omit<import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
2
|
+
name: "blog_categories";
|
|
3
|
+
schema: undefined;
|
|
4
|
+
columns: {
|
|
5
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
6
|
+
name: "id";
|
|
7
|
+
tableName: "blog_categories";
|
|
8
|
+
dataType: "number";
|
|
9
|
+
columnType: "PgSerial";
|
|
10
|
+
data: number;
|
|
11
|
+
driverParam: number;
|
|
12
|
+
notNull: true;
|
|
13
|
+
hasDefault: true;
|
|
14
|
+
isPrimaryKey: true;
|
|
15
|
+
isAutoincrement: false;
|
|
16
|
+
hasRuntimeDefault: false;
|
|
17
|
+
enumValues: undefined;
|
|
18
|
+
baseColumn: never;
|
|
19
|
+
identity: undefined;
|
|
20
|
+
generated: undefined;
|
|
21
|
+
}, {}, {}>;
|
|
22
|
+
title: import("drizzle-orm/pg-core").PgColumn<{
|
|
23
|
+
name: "title";
|
|
24
|
+
tableName: "blog_categories";
|
|
25
|
+
dataType: "string";
|
|
26
|
+
columnType: "PgVarchar";
|
|
27
|
+
data: string;
|
|
28
|
+
driverParam: string;
|
|
29
|
+
notNull: true;
|
|
30
|
+
hasDefault: false;
|
|
31
|
+
isPrimaryKey: false;
|
|
32
|
+
isAutoincrement: false;
|
|
33
|
+
hasRuntimeDefault: false;
|
|
34
|
+
enumValues: [string, ...string[]];
|
|
35
|
+
baseColumn: never;
|
|
36
|
+
identity: undefined;
|
|
37
|
+
generated: undefined;
|
|
38
|
+
}, {}, {
|
|
39
|
+
length: 100;
|
|
40
|
+
}>;
|
|
41
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
42
|
+
name: "createdAt";
|
|
43
|
+
tableName: "blog_categories";
|
|
44
|
+
dataType: "date";
|
|
45
|
+
columnType: "PgTimestamp";
|
|
46
|
+
data: Date;
|
|
47
|
+
driverParam: string;
|
|
48
|
+
notNull: true;
|
|
49
|
+
hasDefault: true;
|
|
50
|
+
isPrimaryKey: false;
|
|
51
|
+
isAutoincrement: false;
|
|
52
|
+
hasRuntimeDefault: false;
|
|
53
|
+
enumValues: undefined;
|
|
54
|
+
baseColumn: never;
|
|
55
|
+
identity: undefined;
|
|
56
|
+
generated: undefined;
|
|
57
|
+
}, {}, {}>;
|
|
58
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
59
|
+
name: "updatedAt";
|
|
60
|
+
tableName: "blog_categories";
|
|
61
|
+
dataType: "date";
|
|
62
|
+
columnType: "PgTimestamp";
|
|
63
|
+
data: Date;
|
|
64
|
+
driverParam: string;
|
|
65
|
+
notNull: true;
|
|
66
|
+
hasDefault: true;
|
|
67
|
+
isPrimaryKey: false;
|
|
68
|
+
isAutoincrement: false;
|
|
69
|
+
hasRuntimeDefault: false;
|
|
70
|
+
enumValues: undefined;
|
|
71
|
+
baseColumn: never;
|
|
72
|
+
identity: undefined;
|
|
73
|
+
generated: undefined;
|
|
74
|
+
}, {}, {}>;
|
|
75
|
+
titleSeo: import("drizzle-orm/pg-core").PgColumn<{
|
|
76
|
+
name: "titleSeo";
|
|
77
|
+
tableName: "blog_categories";
|
|
78
|
+
dataType: "string";
|
|
79
|
+
columnType: "PgVarchar";
|
|
80
|
+
data: string;
|
|
81
|
+
driverParam: string;
|
|
82
|
+
notNull: true;
|
|
83
|
+
hasDefault: true;
|
|
84
|
+
isPrimaryKey: false;
|
|
85
|
+
isAutoincrement: false;
|
|
86
|
+
hasRuntimeDefault: false;
|
|
87
|
+
enumValues: [string, ...string[]];
|
|
88
|
+
baseColumn: never;
|
|
89
|
+
identity: undefined;
|
|
90
|
+
generated: undefined;
|
|
91
|
+
}, {}, {
|
|
92
|
+
length: 100;
|
|
93
|
+
}>;
|
|
94
|
+
};
|
|
95
|
+
dialect: "pg";
|
|
96
|
+
}>, "enableRLS">;
|
|
97
|
+
//# sourceMappingURL=categories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"categories.d.ts","sourceRoot":"","sources":["../../../src/database/categories.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBASb,CAAC"}
|