feat: 优化项目目录结构
This commit is contained in:
12
apps/frontend/lib/api/blog/createComment.ts
Normal file
12
apps/frontend/lib/api/blog/createComment.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { BlogComment } from "@/lib/types/blogComment";
|
||||
import fetcher from "../fetcher";
|
||||
|
||||
export async function createComment(blogId: string, content: string, parentId?: string) {
|
||||
return fetcher<BlogComment>(`/api/blog/${blogId}/comment`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
content,
|
||||
parentId: parentId || null,
|
||||
}),
|
||||
});
|
||||
}
|
||||
13
apps/frontend/lib/api/blog/get.ts
Normal file
13
apps/frontend/lib/api/blog/get.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import fetcher from "../fetcher";
|
||||
|
||||
export async function get(id: string, option: {
|
||||
password?: string;
|
||||
} = {}) {
|
||||
const { password } = option;
|
||||
return fetcher<{
|
||||
id: string;
|
||||
title: string;
|
||||
createdAt: string;
|
||||
content: string;
|
||||
}>(`/api/blog/${id}` + (password ? `?p=${password}` : ''));
|
||||
}
|
||||
6
apps/frontend/lib/api/blog/getComments.ts
Normal file
6
apps/frontend/lib/api/blog/getComments.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { BlogComment } from "@/lib/types/blogComment";
|
||||
import fetcher from "../fetcher";
|
||||
|
||||
export async function getComments(blogId: string) {
|
||||
return fetcher<BlogComment[]>(`/api/blog/${blogId}/comments`, { method: 'GET' });
|
||||
}
|
||||
4
apps/frontend/lib/api/blog/index.ts
Normal file
4
apps/frontend/lib/api/blog/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export * from './list';
|
||||
export * from './get';
|
||||
export * from './getComments';
|
||||
export * from './createComment';
|
||||
6
apps/frontend/lib/api/blog/list.ts
Normal file
6
apps/frontend/lib/api/blog/list.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { Blog } from "@/lib/types/blog";
|
||||
import fetcher from "../fetcher";
|
||||
|
||||
export async function list() {
|
||||
return fetcher<Blog[]>('/api/blog');
|
||||
}
|
||||
Reference in New Issue
Block a user