feat: implement article management features with CRUD operations
Some checks failed
Build and Test / run-test (20.x) (push) Has been cancelled
Some checks failed
Build and Test / run-test (20.x) (push) Has been cancelled
This commit is contained in:
45
src/lib/feature/article/article.model.ts
Normal file
45
src/lib/feature/article/article.model.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { Pagination } from '@/utils/types/pagination';
|
||||
import { z } from 'zod';
|
||||
|
||||
export const CreateArticleModel = z.object({
|
||||
title: z.string(),
|
||||
slug: z.string(),
|
||||
description: z.string(),
|
||||
coverImageUrl: z.string(),
|
||||
content: z.string(),
|
||||
authorId: z.string().optional(),
|
||||
});
|
||||
export type CreateArticleModel = z.infer<typeof CreateArticleModel>;
|
||||
|
||||
export const UpdateArticleModel = z.object({
|
||||
title: z.string().optional(),
|
||||
slug: z.string().optional(),
|
||||
description: z.string().optional(),
|
||||
coverImageUrl: z.string().optional(),
|
||||
content: z.string().optional(),
|
||||
});
|
||||
export type UpdateArticleModel = z.infer<typeof UpdateArticleModel>;
|
||||
|
||||
export const ArticleModel = z.object({
|
||||
id: z.string(),
|
||||
title: z.string(),
|
||||
slug: z.string(),
|
||||
description: z.string(),
|
||||
coverImageUrl: z.string(),
|
||||
content: z.string(),
|
||||
authorId: z.string(),
|
||||
externalId: z.uuid(),
|
||||
});
|
||||
export type ArticleModel = z.infer<typeof ArticleModel>;
|
||||
|
||||
export const ArticleInfoModel = z.object({
|
||||
externalId: z.uuid(),
|
||||
title: z.string(),
|
||||
slug: z.string(),
|
||||
description: z.string(),
|
||||
coverImageUrl: z.string(),
|
||||
});
|
||||
export type ArticleInfoModel = z.infer<typeof ArticleInfoModel>;
|
||||
|
||||
export const PaginatedArticlesResult = Pagination(ArticleModel);
|
||||
export type PaginatedArticlesResult = z.infer<typeof PaginatedArticlesResult>;
|
||||
Reference in New Issue
Block a user