-
-
Notifications
You must be signed in to change notification settings - Fork 168
Expand file tree
/
Copy pathpost.ts
More file actions
85 lines (73 loc) · 2.12 KB
/
post.ts
File metadata and controls
85 lines (73 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import z from "zod";
export const CreatePostSchema = z.object({
body: z.string().trim(),
title: z.string().trim().max(100, "Max title length is 100 characters."),
});
export const LikePostSchema = z.object({
postId: z.string(),
setLiked: z.boolean(),
});
export const BookmarkPostSchema = z.object({
postId: z.string(),
setBookmarked: z.boolean(),
});
export const SavePostSchema = z.object({
body: z.string().trim(),
id: z.string(),
title: z.string().trim().max(100, "Max title length is 100 characters."),
excerpt: z.optional(
z.string().trim().max(156, "Max length is 156 characters."),
),
canonicalUrl: z.optional(z.string().trim().url()),
tags: z.string().array().max(5).optional(),
published: z.string().datetime().optional(),
seriesName: z.string()
.trim()
.optional()
});
export const PublishPostSchema = z.object({
id: z.string(),
published: z.boolean(),
publishTime: z.date().optional(),
});
export const ConfirmPostSchema = z.object({
body: z
.string()
.trim()
.min(50, "Content is too short. Minimum of 50 characters."),
title: z
.string()
.trim()
.max(100, "Max title length is 100 characters.")
.min(10, "Title is too short. Minimum of 10 characters."),
excerpt: z
.string()
.trim()
.max(156, "Max length is 156 characters.")
.optional(),
canonicalUrl: z.string().trim().url().optional(),
tags: z.string().array().max(5).optional(),
});
export const DeletePostSchema = z.object({
id: z.string(),
});
export const GetPostsSchema = z.object({
userId: z.string().optional(),
limit: z.number().min(1).max(100).nullish(),
cursor: z
.object({ id: z.string(), published: z.string(), likes: z.number() })
.nullish(),
sort: z.enum(["newest", "oldest", "top"]),
tag: z.string().nullish(),
});
export type SavePostInput = z.TypeOf<typeof SavePostSchema>;
export type ConfirmPostInput = z.TypeOf<typeof ConfirmPostSchema>;
export const GetSinglePostSchema = z.object({
slug: z.string(),
});
export const GetByIdSchema = z.object({
id: z.string(),
});
export const GetLimitSidePosts = z.object({
limit: z.number().optional(),
});