-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from boostcamp-2020/web_release
WEB : 2주차 release 버전 master 로 합침니다.
Showing
70 changed files
with
18,972 additions
and
494 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
git stash | ||
git checkout master | ||
git pull | ||
npm run build | ||
pm2 stop npm | ||
pm2 delete npm | ||
pm2 start npm -- start |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* eslint-disable no-await-in-loop */ | ||
/* eslint-disable no-restricted-syntax */ | ||
import { Request, Response } from "express"; | ||
import AssigneeModel from "@models/assignee"; | ||
import { Assignee } from "@interfaces/assignee"; | ||
import HTTPCODE from "@root/magicnumber"; | ||
|
||
const get = async (req: Request, res: Response): Promise<Response> => { | ||
try { | ||
const result = await AssigneeModel.select(+req.params.issueid); | ||
return res.json(result); | ||
} catch { | ||
return res.sendStatus(HTTPCODE.SERVER_ERR); | ||
} | ||
}; | ||
|
||
const edit = async (req: Request, res: Response): Promise<Response> => { | ||
try { | ||
const data = await AssigneeModel.select(+req.params.issueid); | ||
const ids = data.map((value) => Number(value.id)); | ||
for (const id of ids) { | ||
const result = await AssigneeModel.del(id); | ||
if (result === HTTPCODE.FAIL) return res.sendStatus(result); | ||
if (result === HTTPCODE.SERVER_ERR) return res.sendStatus(result); | ||
} | ||
const issueId = Number(req.params.issueid); | ||
const assignees = req.body.assignees.map((value: number) => { | ||
const assignee: Assignee = { | ||
id: null, | ||
issue_id: issueId, | ||
user_id: value, | ||
}; | ||
return assignee; | ||
}); | ||
|
||
for (const assignee of assignees) { | ||
const result = await AssigneeModel.add(assignee); | ||
if (result === HTTPCODE.FAIL) return res.sendStatus(result); | ||
if (result === HTTPCODE.SERVER_ERR) return res.sendStatus(result); | ||
} | ||
return res.sendStatus(HTTPCODE.SUCCESS); | ||
} catch { | ||
return res.sendStatus(HTTPCODE.SERVER_ERR); | ||
} | ||
}; | ||
|
||
export default { get, edit }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,61 @@ | ||
import { Request, Response } from "express"; | ||
import passport from "passport"; | ||
import jwt from "jsonwebtoken"; | ||
import dotenv from "dotenv"; | ||
import path from "path"; | ||
|
||
import userController from "@controllers/user"; | ||
|
||
dotenv.config({ path: path.join(__dirname, "../../.env") }); | ||
|
||
function login(req: Request, res: Response): void { | ||
passport.authenticate("local", (err, userResult) => { | ||
if (err || !userResult) { | ||
return res.status(400).json({ | ||
message: "Something is not right", | ||
user: userResult, | ||
}); | ||
} | ||
req.login(userResult, (error) => { | ||
if (error) { | ||
return res.send(error); | ||
passport.authenticate( | ||
"local", | ||
async (err, userResult): Promise<any> => { | ||
if (err || !userResult) { | ||
return res.status(400).json({ | ||
message: "Something is not right", | ||
}); | ||
} | ||
return res.json({ userResult }); | ||
}); | ||
})(req, res); | ||
const loginId = userResult.userID; | ||
const rawPassword = userResult.password; | ||
const searchResult = await userController.find(loginId, rawPassword); | ||
if (searchResult) { | ||
req.login(userResult, (error) => { | ||
if (error) { | ||
return res.send(error); | ||
} | ||
const JWT = jwt.sign(JSON.parse(JSON.stringify(userResult)), String(process.env.JWT_SECRET), { expiresIn: "10m" }); | ||
return res.json({ state: "success", JWT }); | ||
}); | ||
} else { | ||
return res.json({ state: "fail" }); | ||
} | ||
} | ||
)(req, res); | ||
} | ||
function logout(req: Request, res: Response): any { | ||
req.logout(); | ||
return res.json({ state: "success" }); | ||
function githubLogin(req: Request, res: Response): Response<JSON> | Response<string> { | ||
const gitUser: any = req.user; | ||
const userResult = gitUser.profile.username; | ||
const JWT = jwt.sign(JSON.parse(JSON.stringify({ userResult })), String(process.env.JWT_SECRET), { expiresIn: "10m" }); | ||
return res.json({ state: "success", JWT }); | ||
} | ||
function apple(req: Request, res: Response): Response<JSON> | Response<string> { | ||
const loginUser: any = req.body; | ||
const decoded: any = jwt.decode(loginUser.identity_token); | ||
const userEmail: string = decoded.email; | ||
const userResult = userEmail.split("@")[0]; | ||
const JWT = jwt.sign(JSON.parse(JSON.stringify({ userResult })), String(process.env.JWT_SECRET), { expiresIn: "10m" }); | ||
return res.json({ state: "success", JWT }); | ||
} | ||
function githubLogin(req: Request, res: Response): any { | ||
|
||
function logout(req: Request, res: Response): Response<JSON> { | ||
req.logout(); | ||
return res.json({ state: "success" }); | ||
} | ||
function githubLoginFail(req: Request, res: Response): any { | ||
|
||
function githubLoginFail(req: Request, res: Response): Response<JSON> { | ||
return res.json({ state: "fail" }); | ||
} | ||
const github = passport.authenticate("github", { failureRedirect: "/auth/github/loginFail" }); | ||
export default { login, logout, githubLogin, githubLoginFail, github }; | ||
export default { login, logout, githubLogin, githubLoginFail, github, apple }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Request, Response } from "express"; | ||
import CommentModel from "@models/comment"; | ||
import { Comment } from "@interfaces/comment"; | ||
import HTTPCODE from "@root/magicnumber"; | ||
|
||
const get = async (req: Request, res: Response): Promise<Response> => { | ||
try { | ||
const result = await CommentModel.select(+req.params.issueid); | ||
return res.json(result); | ||
} catch { | ||
return res.sendStatus(HTTPCODE.SERVER_ERR); | ||
} | ||
}; | ||
|
||
const add = async (req: Request, res: Response): Promise<Response> => { | ||
const comment: Comment = { | ||
id: null, | ||
issue_id: req.body.issue_id, | ||
user_id: req.body.user_id, | ||
body: req.body.body, | ||
emoji: req.body.emoji, | ||
created_at: new Date(), | ||
}; | ||
const result = await CommentModel.add(comment); | ||
return res.sendStatus(result); | ||
}; | ||
|
||
const edit = async (req: Request, res: Response): Promise<Response> => { | ||
const comment = { | ||
id: req.body.id, | ||
issue_id: req.body.issue_id, | ||
user_id: req.body.user_id, | ||
body: req.body.body, | ||
emoji: req.body.emoji, | ||
}; | ||
const result = await CommentModel.edit(comment); | ||
return res.sendStatus(result); | ||
}; | ||
|
||
const del = async (req: Request, res: Response): Promise<Response> => { | ||
const result = await CommentModel.del(+req.body.id); | ||
return res.sendStatus(result); | ||
}; | ||
|
||
export default { get, add, edit, del }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Request, Response } from "express"; | ||
import { Event } from "@interfaces/event"; | ||
import EventModel from "@models/event"; | ||
import HTTPCODE from "@root/magicnumber"; | ||
|
||
const get = async (req: Request, res: Response): Promise<Response<any>> => { | ||
const { issueid } = req.params; | ||
try { | ||
const result = await EventModel.select(Number(issueid)); | ||
return res.json(result); | ||
} catch { | ||
return res.sendStatus(HTTPCODE.SERVER_ERR); | ||
} | ||
}; | ||
|
||
const add = async (req: Request, res: Response): Promise<Response<any>> => { | ||
const event: Event = { | ||
id: null, | ||
issue_id: Number(req.params.issueid), | ||
user_id: req.body.user_id, | ||
log: req.body.log, | ||
created_at: new Date(), | ||
}; | ||
const result = await EventModel.add(event); | ||
return res.sendStatus(result); | ||
}; | ||
|
||
export default { get, add }; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Request, Response } from "express"; | ||
import IssueModel from "@models/issue"; | ||
import { Issue } from "@interfaces/issue"; | ||
import HTTPCODE from "@root/magicnumber"; | ||
|
||
const get = async (req: Request, res: Response): Promise<any> => { | ||
try { | ||
const result = await IssueModel.select(); | ||
return res.json(result); | ||
} catch { | ||
return res.sendStatus(HTTPCODE.SERVER_ERR); | ||
} | ||
}; | ||
|
||
const add = async (req: Request, res: Response): Promise<any> => { | ||
const issue: Issue = { | ||
id: null, | ||
title: req.body.title, | ||
body: req.body.body, | ||
user_id: req.body.author, | ||
created_at: new Date(), | ||
closed_at: req.body?.closed_at ?? null, | ||
state: true, | ||
milestone_id: req.body?.milestone_at ?? null, | ||
}; | ||
const result = await IssueModel.add(issue); | ||
return res.sendStatus(result); | ||
}; | ||
|
||
const edit = async (req: Request, res: Response): Promise<any> => { | ||
const issue = { | ||
id: req.body.id, | ||
title: req.body.title, | ||
body: req.body.body, | ||
user_id: req.body.author, | ||
closed_at: req.body?.closed_at ?? null, | ||
state: req.body.state, | ||
milestone_id: req.body?.milestone_id ?? null, | ||
}; | ||
const result = await IssueModel.edit(issue); | ||
return res.sendStatus(result); | ||
}; | ||
|
||
const del = async (req: Request, res: Response): Promise<any> => { | ||
const result = await IssueModel.del(req.body.id); | ||
return res.sendStatus(result); | ||
}; | ||
|
||
const changeState = async (req: Request, res: Response): Promise<any> => { | ||
const result = await IssueModel.changeState(+req.params.id, !!+req.params.state); | ||
return res.sendStatus(result); | ||
}; | ||
|
||
export default { get, add, edit, del, changeState }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Request, Response } from "express"; | ||
import LabelModel from "@models/label"; | ||
import { Label } from "@interfaces/label"; | ||
import HTTPCODE from "@root/magicnumber"; | ||
|
||
const get = async (req: Request, res: Response): Promise<any> => { | ||
try { | ||
const result = await LabelModel.select(); | ||
return res.json(result); | ||
} catch { | ||
return res.sendStatus(HTTPCODE.SERVER_ERR); | ||
} | ||
}; | ||
|
||
const add = async (req: Request, res: Response): Promise<any> => { | ||
const label: Label = { | ||
id: null, | ||
name: req.body.name, | ||
description: req.body.description, | ||
color: req.body.color, | ||
created_at: new Date(), | ||
}; | ||
const result = await LabelModel.add(label); | ||
return res.sendStatus(result); | ||
}; | ||
const edit = async (req: Request, res: Response): Promise<any> => { | ||
const label = { | ||
id: req.body.id, | ||
name: req.body.name, | ||
description: req.body.description, | ||
color: req.body.color, | ||
}; | ||
const result = await LabelModel.edit(label); | ||
return res.sendStatus(result); | ||
}; | ||
|
||
const del = async (req: Request, res: Response): Promise<any> => { | ||
const { id } = req.body; | ||
const result = await LabelModel.del(id); | ||
return res.sendStatus(result); | ||
}; | ||
|
||
export default { get, add, edit, del }; |
Oops, something went wrong.