Skip to content

Commit c7e98fb

Browse files
committed
[Add] Add conditional braces #15
1 parent b4e487b commit c7e98fb

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

server/app/src/apis/visitor/visitor.ctrl.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { BadRequestError } from '../../service/error';
55
import errorResposne from '../module/error';
66

77
/**
8-
* @method patch - /apis/visitor/count
8+
* @method patch /apis/visitor/count
99
*/
1010
const updateAndGetVisitor = async (req: Request, res: Response) => {
1111
try {
@@ -20,32 +20,34 @@ const updateAndGetVisitor = async (req: Request, res: Response) => {
2020
};
2121

2222
/**
23-
* @method post - /apis/visitor/comment
23+
* @method post /apis/visitor/comment
2424
*/
2525
const createVisitComment = async (req: Request, res: Response) => {
2626
const RequestVisitorComment = Object.assign(req.body);
2727

2828
try {
29-
if (RequestVisitorComment.nickname?.length === 0)
29+
if (RequestVisitorComment.nickname?.length === 0) {
3030
req.body.nickname = '익명';
31+
}
3132

3233
const visitor = new Visitor(new VisitorRepository(), RequestVisitorComment);
3334

3435
const response = await visitor.createComment();
3536

36-
if (response)
37+
if (response) {
3738
return res.status(201).json({
3839
statusCode: 201,
3940
commentId: response,
4041
msg: 'Successful visitor comment creation',
4142
});
43+
}
4244
} catch (err) {
4345
return errorResposne(err, res);
4446
}
4547
};
4648

4749
/**
48-
* @method patch - /apis/visitor/comment/{id}
50+
* @method patch /apis/visitor/comment/{id}
4951
*/
5052
const updateVisitCommentById = async (req: Request, res: Response) => {
5153
const { id: visitorCommentId } = req.params;
@@ -57,16 +59,17 @@ const updateVisitCommentById = async (req: Request, res: Response) => {
5759

5860
const response = await visitor.updateCommentById(Number(visitorCommentId));
5961

60-
if (!response.success)
62+
if (!response.success) {
6163
return res.status(401).json({ statusCode: 401, msg: response.msg });
64+
}
6265
return res.status(200).json({ statusCode: 200, msg: response.msg });
6366
} catch (err) {
6467
return errorResposne(err, res);
6568
}
6669
};
6770

6871
/**
69-
* @method get - /apis/visitor/comments
72+
* @method get /apis/visitor/comments
7073
*/
7174
const getVisitorComments = async (req: Request, res: Response) => {
7275
try {
@@ -81,25 +84,27 @@ const getVisitorComments = async (req: Request, res: Response) => {
8184
};
8285

8386
/**
84-
* @method delete - /apis/visitor/comment/{id}
87+
* @method delete /apis/visitor/comment/{id}
8588
*/
8689
const deleteVisitorCommentById = async (req: Request, res: Response) => {
8790
try {
8891
const visitorCommentId = req.params.id;
8992

90-
if (!visitorCommentId) throw new BadRequestError('id params is undefined');
91-
93+
if (!visitorCommentId) {
94+
throw new BadRequestError('id params is undefined');
95+
}
9296
const visitor = new Visitor(new VisitorRepository());
9397

9498
const response = await visitor.deleteVisitorCommentById(
9599
Number(visitorCommentId)
96100
);
97101

98-
if (response)
102+
if (response) {
99103
return res.status(200).json({
100104
statusCode: 200,
101105
msg: 'Successful deletion of visitor comment',
102106
});
107+
}
103108
} catch (err) {
104109
return errorResposne(err, res);
105110
}

0 commit comments

Comments
 (0)