generated from samchon/backend
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathBbsArticlesController.ts
125 lines (117 loc) · 3.34 KB
/
BbsArticlesController.ts
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import core from "@nestia/core";
import { Controller, Request } from "@nestjs/common";
import { FastifyRequest } from "fastify";
import { tags } from "typia";
import { IBbsArticle } from "@samchon/bbs-api/lib/structures/bbs/IBbsArticle";
import { IPage } from "@samchon/bbs-api/lib/structures/common/IPage";
import { BbsArticleProvider } from "../../providers/bbs/BbsArticleProvider";
@Controller("bbs/articles")
export class BbsArticlesController {
/**
* List up all summarized articles.
*
* List up all summarized articles with pagination and searching options.
*
* @param input Request info of pagination and searching options.
* @returns Paginated summarized articles.
* @tag BBS
*
* @author Samchon
*/
@core.TypedRoute.Patch()
public index(
@core.TypedBody() input: IBbsArticle.IRequest,
): Promise<IPage<IBbsArticle.ISummary>> {
return BbsArticleProvider.index(input);
}
/**
* List up all abridged articles.
*
* List up all abridged articles with pagination and searching options.
*
* @param input Request info of pagination and searching options.
* @returns Paginated abridged articles.
* @tag BBS
*
* @author Samchon
*/
@core.TypedRoute.Patch("abridges")
public abridges(
@core.TypedBody() input: IBbsArticle.IRequest,
): Promise<IPage<IBbsArticle.IAbridge>> {
return BbsArticleProvider.abridges(input);
}
/**
* Read individual article.
*
* Reads an article with its every {@link IBbsArticle.ISnapshot snapshots}.
*
* @param id Target article's {@link IBbsArticle.id}
* @returns Article information
* @tag BBS
*
* @author Samchon
*/
@core.TypedRoute.Get(":id")
public at(
@core.TypedParam("id") id: string & tags.Format<"uuid">,
): Promise<IBbsArticle> {
return BbsArticleProvider.at(id);
}
/**
* Create a new article.
*
* Create a new article with its first {@link IBbsArticle.ISnapshot snapshot}.
*
* @param input Article information to create.
* @returns Newly created article.
* @tag BBS
*
* @author Samchon
*/
@core.TypedRoute.Post()
public create(
@Request() request: FastifyRequest,
@core.TypedBody() input: IBbsArticle.ICreate,
): Promise<IBbsArticle> {
return BbsArticleProvider.create(input, request.ip);
}
/**
* Update an article.
*
* Accumulate a new {@link IBbsArticle.ISnapshot snapshot} record to the article.
*
* @param id Target article's {@link IBbsArticle.id}
* @param input Article information to update.
* @returns Newly accumulated snapshot information.
* @tag BBS
*
* @author Samchon
*/
@core.TypedRoute.Put(":id")
public update(
@Request() request: FastifyRequest,
@core.TypedParam("id") id: string & tags.Format<"uuid">,
@core.TypedBody() input: IBbsArticle.IUpdate,
): Promise<IBbsArticle.ISnapshot> {
return BbsArticleProvider.update(id)(input, request.ip);
}
/**
* Erase an article.
*
* Performs soft deletion to the article.
*
* @param id Target article's {@link IBbsArticle.id}
* @param input Password of the article.
* @tag BBS
*
* @author Samchon
*/
@core.TypedRoute.Delete(":id")
public erase(
@core.TypedParam("id") id: string & tags.Format<"uuid">,
@core.TypedBody() input: IBbsArticle.IErase,
): Promise<void> {
return BbsArticleProvider.erase(id)(input);
}
}