@vitnode/blog 1.2.0-canary.53 → 1.2.0-canary.54

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.
@@ -1 +1 @@
1
- import{buildModule}from"@vitnode/core/api/lib/module";import{CONFIG_PLUGIN}from"../../../const.js";import{categoriesAdminModule}from"./categories/categories.admin.module.js";import{postsAdminModule}from"./posts/posts.admin.module.js";export const adminModule=buildModule({...CONFIG_PLUGIN,name:"admin",modules:[categoriesAdminModule,postsAdminModule],routes:[]});
1
+ import{buildModule}from"@vitnode/core/api/lib/module";import{CONFIG_PLUGIN}from"../../../const.js";import{categoriesAdminModule}from"./categories/categories.admin.module.js";import{postsAdminModule}from"./posts/posts.admin.module.js";export const adminModule=buildModule({pluginId:CONFIG_PLUGIN.pluginId,name:"admin",modules:[categoriesAdminModule,postsAdminModule],routes:[]});
@@ -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";export const categoriesAdminModule=buildModule({...CONFIG_PLUGIN,name:"categories",routes:[createCategoryRoute,editCategoryRoute,deleteCategoryRoute]});
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";export const categoriesAdminModule=buildModule({pluginId:CONFIG_PLUGIN.pluginId,name:"categories",routes:[createCategoryRoute,editCategoryRoute,deleteCategoryRoute]});
@@ -1 +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";const zodCategoryResponseSchema=z.object({id:z.number(),title:z.string(),createdAt:z.date(),updatedAt:z.date()});export const zodCreateCategorySchema=z.object({title:z.string()});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
+ 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";const zodCategoryResponseSchema=z.object({id:z.number(),title:z.string(),createdAt:z.date(),updatedAt:z.date()});export const zodCreateCategorySchema=z.object({title:z.string()});export const createCategoryRoute=buildRoute({pluginId:CONFIG_PLUGIN.pluginId,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 +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_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
+ 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({pluginId:CONFIG_PLUGIN.pluginId,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 +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)}});
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({pluginId:CONFIG_PLUGIN.pluginId,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 +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]});
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({pluginId:CONFIG_PLUGIN.pluginId,name:"posts",routes:[editPostRoute,createPostRoute,deletePostRoute]});
@@ -1 +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";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 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()});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
+ 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";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 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()});export const createPostRoute=buildRoute({pluginId:CONFIG_PLUGIN.pluginId,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 +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
+ 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({pluginId:CONFIG_PLUGIN.pluginId,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 +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
+ 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({pluginId:CONFIG_PLUGIN.pluginId,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 +1 @@
1
- import{buildModule}from"@vitnode/core/api/lib/module";import{CONFIG_PLUGIN}from"../../../const.js";import{categoriesRoute}from"./routes/get.route.js";import{testRoute}from"./test.route.js";export const categoriesModule=buildModule({...CONFIG_PLUGIN,name:"categories",routes:[categoriesRoute,testRoute]});
1
+ import{buildModule}from"@vitnode/core/api/lib/module";import{CONFIG_PLUGIN}from"../../../const.js";import{categoriesRoute}from"./routes/get.route.js";import{testRoute}from"./test.route.js";export const categoriesModule=buildModule({pluginId:CONFIG_PLUGIN.pluginId,name:"categories",routes:[categoriesRoute,testRoute]});
@@ -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{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;let combinedWhere;if(searchCondition){if(where){combinedWhere=and(where,searchCondition)}else{combinedWhere=searchCondition}}else{combinedWhere=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)}});
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({pluginId:CONFIG_PLUGIN.pluginId,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;let combinedWhere;if(searchCondition){if(where){combinedWhere=and(where,searchCondition)}else{combinedWhere=searchCondition}}else{combinedWhere=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)}});
@@ -1 +1 @@
1
- import{buildRoute}from"@vitnode/core/api/lib/route";import{UserModel}from"@vitnode/core/api/models/user";import{z}from"zod";import{CONFIG_PLUGIN}from"../../../const.js";import TestTemplateEmail from"../../../emails/test-template.js";export const testRoute=buildRoute({...CONFIG_PLUGIN,route:{method:"post",description:"Test route",path:"/test",responses:{200:{content:{"text/plain":{schema:z.string()}},description:"User"},201:{content:{"text/plain":{schema:z.string()}},description:"User"}}},handler:async c=>{const user=await new UserModel().getUserById({id:3,c});if(!user)throw new Error("User not found");await c.get("email").send({subject:"Test Email",content:TestTemplateEmail,user});await c.get("log").warn("This is a test warn log");return c.text("test")}});
1
+ import{buildRoute}from"@vitnode/core/api/lib/route";import{UserModel}from"@vitnode/core/api/models/user";import{z}from"zod";import{CONFIG_PLUGIN}from"../../../const.js";import TestTemplateEmail from"../../../emails/test-template.js";export const testRoute=buildRoute({pluginId:CONFIG_PLUGIN.pluginId,route:{method:"post",description:"Test route",path:"/test",responses:{200:{content:{"text/plain":{schema:z.string()}},description:"User"},201:{content:{"text/plain":{schema:z.string()}},description:"User"}}},handler:async c=>{const user=await new UserModel().getUserById({id:3,c});if(!user)throw new Error("User not found");await c.get("email").send({subject:"Test Email",content:TestTemplateEmail,user});await c.get("log").warn("This is a test warn log");return c.text("test")}});
@@ -1 +1 @@
1
- import{buildModule}from"@vitnode/core/api/lib/module";import{CONFIG_PLUGIN}from"../../../const.js";import{postsRoute}from"./routes/get.route.js";export const postsModule=buildModule({...CONFIG_PLUGIN,name:"posts",routes:[postsRoute]});
1
+ import{buildModule}from"@vitnode/core/api/lib/module";import{CONFIG_PLUGIN}from"../../../const.js";import{postsRoute}from"./routes/get.route.js";export const postsModule=buildModule({pluginId:CONFIG_PLUGIN.pluginId,name:"posts",routes:[postsRoute]});
@@ -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{eq}from"drizzle-orm";import{CONFIG_PLUGIN}from"../../../../const.js";import{blog_categories}from"../../../../database/categories.js";import{blog_posts}from"../../../../database/posts.js";export 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)}});
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"../../../../const.js";import{blog_categories}from"../../../../database/categories.js";import{blog_posts}from"../../../../database/posts.js";export 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({pluginId:CONFIG_PLUGIN.pluginId,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)}});
@@ -1 +1 @@
1
- import{buildApiPlugin}from"@vitnode/core/api/lib/plugin";import{CONFIG_PLUGIN}from"./const.js";import{adminModule}from"./api/modules/admin/admin.module.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:[adminModule,categoriesModule,postsModule]})};
1
+ import{buildApiPlugin}from"@vitnode/core/api/lib/plugin";import{CONFIG_PLUGIN}from"./const.js";import{adminModule}from"./api/modules/admin/admin.module.js";import{categoriesModule}from"./api/modules/categories/categories.module.js";import{postsModule}from"./api/modules/posts/posts.module.js";export const blogApiPlugin=()=>{return buildApiPlugin({pluginId:CONFIG_PLUGIN.pluginId,modules:[adminModule,categoriesModule,postsModule]})};
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{buildPlugin}from"@vitnode/core/lib/plugin";import{ListIcon,NotebookPenIcon}from"lucide-react";import{CONFIG_PLUGIN}from"./const.js";export const blogPlugin=()=>{return buildPlugin({...CONFIG_PLUGIN,admin:{nav:[{id:"posts",href:"/admin/blog/posts",icon:_jsx(NotebookPenIcon,{})},{id:"categories",href:"/admin/blog/categories",icon:_jsx(ListIcon,{})}]}})};
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{buildPlugin}from"@vitnode/core/lib/plugin";import{ListIcon,NotebookPenIcon}from"lucide-react";import{CONFIG_PLUGIN}from"./const.js";export const blogPlugin=()=>{return buildPlugin({pluginId:CONFIG_PLUGIN.pluginId,admin:{nav:[{id:"posts",href:"/admin/blog/posts",icon:_jsx(NotebookPenIcon,{})},{id:"categories",href:"/admin/blog/categories",icon:_jsx(ListIcon,{})}]}})};