박권수

feat. get user's hub List

......@@ -39,6 +39,25 @@ exports.hubConnect = async (ctx) => {
ctx.body = hub;
};
exports.getHubList = async(ctx) => {
const token = ctx.cookies.get('access_token');
if(!token) {
ctx.status = 401;
return;
}
const { userId } = jwt.verify(token, process.env.JWT_SECRET);
const hubList = await Hub.find({ userId });
console.log(hubList)
if(!hubList || !hubList.length) {
ctx.status = 404;
return;
}
ctx.status = 200;
ctx.body = hubList;
};
exports.hubDisconnect = async(ctx) => {
const token = ctx.cookies.get('access_token');
if(!token) {
......
......@@ -12,6 +12,14 @@ const hub = new Router();
hub.post('/', hubCtrl.hubConnect);
/**
* 로그인한 유저의 허브 목록 가져오기
* request parameter : X
* url : http://localhost:4000/api/hub
* return : hub List(json type)
*/
hub.get('/', hubCtrl.getHubList);
/**
* 허브 등록 해제
* request parameter : x
* url : http://localhost:4000/api/hub/:hubId
......