@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.
- package/dist/src/api/modules/admin/admin.module.d.ts +439 -0
- package/dist/src/api/modules/admin/admin.module.d.ts.map +1 -0
- package/dist/src/api/modules/admin/admin.module.js +1 -0
- package/dist/src/api/modules/admin/categories/categories.admin.module.d.ts +198 -0
- package/dist/src/api/modules/admin/categories/categories.admin.module.d.ts.map +1 -0
- package/dist/src/api/modules/admin/categories/categories.admin.module.js +1 -0
- package/dist/src/api/modules/{categories → admin/categories}/routes/create.route.d.ts +1 -1
- package/dist/src/api/modules/admin/categories/routes/create.route.d.ts.map +1 -0
- package/dist/src/api/modules/admin/categories/routes/create.route.js +1 -0
- package/dist/src/api/modules/{categories → admin/categories}/routes/delete.route.d.ts +1 -1
- package/dist/src/api/modules/admin/categories/routes/delete.route.d.ts.map +1 -0
- package/dist/src/api/modules/admin/categories/routes/delete.route.js +1 -0
- package/dist/src/api/modules/{categories → admin/categories}/routes/edit.route.d.ts +1 -1
- package/dist/src/api/modules/admin/categories/routes/edit.route.d.ts.map +1 -0
- package/dist/src/api/modules/admin/categories/routes/edit.route.js +1 -0
- package/dist/src/api/modules/admin/posts/posts.admin.module.d.ts +243 -0
- package/dist/src/api/modules/admin/posts/posts.admin.module.d.ts.map +1 -0
- package/dist/src/api/modules/admin/posts/posts.admin.module.js +1 -0
- package/dist/src/api/modules/{posts → admin/posts}/routes/create.route.d.ts +1 -1
- package/dist/src/api/modules/admin/posts/routes/create.route.d.ts.map +1 -0
- package/dist/src/api/modules/admin/posts/routes/create.route.js +1 -0
- package/dist/src/api/modules/{posts → admin/posts}/routes/delete.route.d.ts +1 -1
- package/dist/src/api/modules/admin/posts/routes/delete.route.d.ts.map +1 -0
- package/dist/src/api/modules/admin/posts/routes/delete.route.js +1 -0
- package/dist/src/api/modules/{posts → admin/posts}/routes/edit.route.d.ts +1 -1
- package/dist/src/api/modules/admin/posts/routes/edit.route.d.ts.map +1 -0
- package/dist/src/api/modules/admin/posts/routes/edit.route.js +1 -0
- package/dist/src/api/modules/categories/categories.module.d.ts +6 -197
- package/dist/src/api/modules/categories/categories.module.d.ts.map +1 -1
- package/dist/src/api/modules/categories/categories.module.js +1 -1
- package/dist/src/api/modules/categories/routes/get.route.d.ts +6 -1
- package/dist/src/api/modules/categories/routes/get.route.d.ts.map +1 -1
- package/dist/src/api/modules/categories/routes/get.route.js +1 -1
- package/dist/src/api/modules/posts/posts.module.d.ts +5 -246
- package/dist/src/api/modules/posts/posts.module.d.ts.map +1 -1
- package/dist/src/api/modules/posts/posts.module.js +1 -1
- package/dist/src/api/modules/posts/routes/get.route.d.ts +53 -5
- package/dist/src/api/modules/posts/routes/get.route.d.ts.map +1 -1
- package/dist/src/api/modules/posts/routes/get.route.js +1 -1
- package/dist/src/app_admin/blog/categories/page.d.ts +5 -1
- package/dist/src/app_admin/blog/categories/page.d.ts.map +1 -1
- package/dist/src/app_admin/blog/categories/page.js +1 -1
- package/dist/src/app_admin/blog/posts/page.d.ts +5 -1
- package/dist/src/app_admin/blog/posts/page.d.ts.map +1 -1
- package/dist/src/app_admin/blog/posts/page.js +1 -1
- package/dist/src/config.api.d.ts.map +1 -1
- package/dist/src/config.api.js +1 -1
- package/dist/src/views/admin/categories/actions/create-edit/create-edit.d.ts +1 -1
- package/dist/src/views/admin/categories/actions/create-edit/create-edit.d.ts.map +1 -1
- package/dist/src/views/admin/categories/actions/create-edit/create-edit.js +1 -1
- package/dist/src/views/admin/categories/actions/create-edit/mutation-api.d.ts +1 -1
- package/dist/src/views/admin/categories/actions/create-edit/mutation-api.d.ts.map +1 -1
- package/dist/src/views/admin/categories/actions/create-edit/mutation-api.js +1 -1
- package/dist/src/views/admin/categories/row-actions/delete/delete-action.d.ts.map +1 -1
- package/dist/src/views/admin/categories/row-actions/delete/delete-action.js +1 -1
- package/dist/src/views/admin/categories/row-actions/delete/mutation-api.d.ts.map +1 -1
- package/dist/src/views/admin/categories/row-actions/delete/mutation-api.js +1 -1
- package/dist/src/views/admin/categories/row-actions/edit-action.d.ts +1 -1
- package/dist/src/views/admin/categories/row-actions/edit-action.d.ts.map +1 -1
- package/dist/src/views/admin/posts/actions/create-edit/create-edit.d.ts +2 -2
- package/dist/src/views/admin/posts/actions/create-edit/create-edit.d.ts.map +1 -1
- package/dist/src/views/admin/posts/actions/create-edit/create-edit.js +1 -1
- package/dist/src/views/admin/posts/actions/create-edit/mutation-api.d.ts +11 -0
- package/dist/src/views/admin/posts/actions/create-edit/mutation-api.d.ts.map +1 -0
- package/dist/src/views/admin/posts/actions/create-edit/mutation-api.js +1 -0
- package/dist/src/views/admin/posts/posts-admin-view.d.ts.map +1 -1
- package/dist/src/views/admin/posts/posts-admin-view.js +1 -1
- package/dist/src/views/admin/posts/row-actions/delete/delete-action.d.ts.map +1 -1
- package/dist/src/views/admin/posts/row-actions/delete/delete-action.js +1 -1
- package/dist/src/views/admin/posts/row-actions/delete/mutation-api.d.ts.map +1 -1
- package/dist/src/views/admin/posts/row-actions/delete/mutation-api.js +1 -1
- package/dist/src/views/admin/posts/row-actions/edit-action.d.ts +9 -0
- package/dist/src/views/admin/posts/row-actions/edit-action.d.ts.map +1 -0
- package/dist/src/views/admin/posts/row-actions/edit-action.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -16
- package/src/app_admin/blog/categories/page.tsx +12 -4
- package/src/app_admin/blog/posts/page.tsx +12 -3
- package/src/locales/en.json +6 -2
- package/dist/src/api/modules/categories/routes/create.route.d.ts.map +0 -1
- package/dist/src/api/modules/categories/routes/create.route.js +0 -1
- package/dist/src/api/modules/categories/routes/delete.route.d.ts.map +0 -1
- package/dist/src/api/modules/categories/routes/delete.route.js +0 -1
- package/dist/src/api/modules/categories/routes/edit.route.d.ts.map +0 -1
- package/dist/src/api/modules/categories/routes/edit.route.js +0 -1
- package/dist/src/api/modules/posts/routes/create.route.d.ts.map +0 -1
- package/dist/src/api/modules/posts/routes/create.route.js +0 -1
- package/dist/src/api/modules/posts/routes/delete.route.d.ts.map +0 -1
- package/dist/src/api/modules/posts/routes/delete.route.js +0 -1
- package/dist/src/api/modules/posts/routes/edit.route.d.ts.map +0 -1
- package/dist/src/api/modules/posts/routes/edit.route.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitnode/blog",
|
|
3
|
-
"version": "1.2.0-canary.
|
|
3
|
+
"version": "1.2.0-canary.24",
|
|
4
4
|
"description": "Blog plugin for VitNode, providing a blogging platform with Next.js and Hono.js.",
|
|
5
5
|
"author": "VitNode Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,30 +27,30 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@hono/zod-openapi": "^0.19.
|
|
31
|
-
"drizzle-kit": "^0.31.
|
|
32
|
-
"drizzle-orm": "^0.44.
|
|
33
|
-
"hono": "^4.
|
|
34
|
-
"lucide-react": "^0.
|
|
35
|
-
"next": "^15.3.
|
|
30
|
+
"@hono/zod-openapi": "^0.19.8",
|
|
31
|
+
"drizzle-kit": "^0.31.1",
|
|
32
|
+
"drizzle-orm": "^0.44.2",
|
|
33
|
+
"hono": "^4.8.2",
|
|
34
|
+
"lucide-react": "^0.517.0",
|
|
35
|
+
"next": "^15.3.4",
|
|
36
36
|
"next-intl": "^4.1.0",
|
|
37
37
|
"react": "^19.1.0",
|
|
38
38
|
"react-dom": "^19.1.0",
|
|
39
|
-
"react-hook-form": "^7.
|
|
39
|
+
"react-hook-form": "^7.58.1",
|
|
40
40
|
"sonner": "^2.0.5",
|
|
41
|
-
"zod": "^3.25.
|
|
42
|
-
"@vitnode/core": "1.2.0-canary.
|
|
41
|
+
"zod": "^3.25.67",
|
|
42
|
+
"@vitnode/core": "1.2.0-canary.24"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@swc/cli": "0.6.0",
|
|
46
|
-
"@swc/core": "^1.
|
|
47
|
-
"@types/react": "^19.1.
|
|
48
|
-
"@types/react-dom": "^19.1.
|
|
46
|
+
"@swc/core": "^1.12.5",
|
|
47
|
+
"@types/react": "^19.1.8",
|
|
48
|
+
"@types/react-dom": "^19.1.6",
|
|
49
49
|
"concurrently": "^9.1.2",
|
|
50
|
-
"eslint": "^9.
|
|
51
|
-
"tsc-alias": "^1.8.
|
|
50
|
+
"eslint": "^9.29.0",
|
|
51
|
+
"tsc-alias": "^1.8.16",
|
|
52
52
|
"typescript": "^5.8.3",
|
|
53
|
-
"@vitnode/eslint-config": "1.2.0-canary.
|
|
53
|
+
"@vitnode/eslint-config": "1.2.0-canary.24"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build:plugins": "tsc && swc src -d dist --config-file .swcrc && tsc-alias -p tsconfig.json",
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import type { Metadata } from 'next';
|
|
2
2
|
|
|
3
3
|
import { I18nProvider } from '@vitnode/core/components/i18n-provider';
|
|
4
|
+
import { DataTableSkeleton } from '@vitnode/core/components/table/data-table';
|
|
4
5
|
import { HeaderContent } from '@vitnode/core/components/ui/header-content';
|
|
5
6
|
import { getTranslations } from 'next-intl/server';
|
|
7
|
+
import React from 'react';
|
|
6
8
|
|
|
7
|
-
import {
|
|
9
|
+
import { ActionsCategoriesAdmin } from '@/views/admin/categories/actions/actions';
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
const CategoriesAdminView = React.lazy(async () =>
|
|
12
|
+
import('@/views/admin/categories/categories-admin-view').then(mod => ({
|
|
13
|
+
default: mod.CategoriesAdminView,
|
|
14
|
+
})),
|
|
15
|
+
);
|
|
10
16
|
|
|
11
17
|
export const generateMetadata = async (): Promise<Metadata> => {
|
|
12
18
|
const t = await getTranslations('@vitnode/blog.admin.nav');
|
|
@@ -26,12 +32,14 @@ export default async function CategoriesPage(
|
|
|
26
32
|
|
|
27
33
|
return (
|
|
28
34
|
<I18nProvider namespaces={['@vitnode/blog.admin.categories']}>
|
|
29
|
-
<div className="
|
|
35
|
+
<div className="p-4">
|
|
30
36
|
<HeaderContent desc={t('desc')} h1={tNav('categories')}>
|
|
31
37
|
<ActionsCategoriesAdmin />
|
|
32
38
|
</HeaderContent>
|
|
33
39
|
|
|
34
|
-
<
|
|
40
|
+
<React.Suspense fallback={<DataTableSkeleton columns={4} />}>
|
|
41
|
+
<CategoriesAdminView {...params} />
|
|
42
|
+
</React.Suspense>
|
|
35
43
|
</div>
|
|
36
44
|
</I18nProvider>
|
|
37
45
|
);
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import type { Metadata } from 'next';
|
|
2
2
|
|
|
3
3
|
import { I18nProvider } from '@vitnode/core/components/i18n-provider';
|
|
4
|
+
import { DataTableSkeleton } from '@vitnode/core/components/table/data-table';
|
|
4
5
|
import { HeaderContent } from '@vitnode/core/components/ui/header-content';
|
|
5
6
|
import { getTranslations } from 'next-intl/server';
|
|
7
|
+
import React from 'react';
|
|
6
8
|
|
|
7
9
|
import { ActionsPostsAdmin } from '@/views/admin/posts/actions/actions';
|
|
8
|
-
|
|
10
|
+
|
|
11
|
+
const PostsAdminView = React.lazy(async () =>
|
|
12
|
+
import('@/views/admin/posts/posts-admin-view').then(mod => ({
|
|
13
|
+
default: mod.PostsAdminView,
|
|
14
|
+
})),
|
|
15
|
+
);
|
|
9
16
|
|
|
10
17
|
export const generateMetadata = async (): Promise<Metadata> => {
|
|
11
18
|
const t = await getTranslations('@vitnode/blog.admin.nav');
|
|
@@ -25,12 +32,14 @@ export default async function PostsPage(
|
|
|
25
32
|
|
|
26
33
|
return (
|
|
27
34
|
<I18nProvider namespaces={['@vitnode/blog.admin.posts']}>
|
|
28
|
-
<div className="
|
|
35
|
+
<div className="p-4">
|
|
29
36
|
<HeaderContent desc={t('desc')} h1={tNav('posts')}>
|
|
30
37
|
<ActionsPostsAdmin />
|
|
31
38
|
</HeaderContent>
|
|
32
39
|
|
|
33
|
-
<
|
|
40
|
+
<React.Suspense fallback={<DataTableSkeleton columns={5} />}>
|
|
41
|
+
<PostsAdminView {...params} />
|
|
42
|
+
</React.Suspense>
|
|
34
43
|
</div>
|
|
35
44
|
</I18nProvider>
|
|
36
45
|
);
|
package/src/locales/en.json
CHANGED
|
@@ -45,8 +45,12 @@
|
|
|
45
45
|
"title": "Create Post",
|
|
46
46
|
"desc": "Write a new article for your blog.",
|
|
47
47
|
"form": {
|
|
48
|
-
"title":
|
|
49
|
-
|
|
48
|
+
"title": {
|
|
49
|
+
"label": "Title",
|
|
50
|
+
"already_exists": "This post title already exists."
|
|
51
|
+
},
|
|
52
|
+
"content": "Content",
|
|
53
|
+
"category": "Category"
|
|
50
54
|
},
|
|
51
55
|
"submit": "Create Post"
|
|
52
56
|
},
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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";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)}});
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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_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)}});
|
|
@@ -1 +0,0 @@
|
|
|
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;AAkBtC,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiF5B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
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)}});
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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().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)}});
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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;AAsBtC,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8FxB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
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)}});
|