Nomad-Wetube : 배포

이은지·2023년 3월 17일
0

유튜브 클론코딩 배포

[오류 정리]

1. aws를 연결한 후 이미지가 전부 깨져서 나올 때

  • pug파일에서 img, video 부분에 crossorigin 속성을 모두 지워주면 정상적으로 표시가 되었다

2. Edit video가 적용 안될 때
[videoController.js]

export const postEdit = async (req, res) => {
  const {
    user: { _id },
  } = req.session;
  const { id } = req.params;
  const { title, description, hashtags } = req.body;
  //  const video = await Video.exists({ _id: id }); //원래 코드
  const video = await Video.findById(id); //수정한 부분
  if (!video) {
    return res.status(404).render("404", { pageTitle: "Video not found." });
  }
  if (String(video.owner) !== String(_id)) {
    console.log(error);
    req.flash("error", "You are not the the owner of the video.");
    return res.status(403).redirect("/");
  }
  await Video.findByIdAndUpdate(id, {
    title,
    description,
    hashtags: Video.formatHashtags(hashtags),
  });
  req.flash("success", "Changes saved.");
  return res.redirect(`/videos/${id}`);
};

Video.findById()

Video.findById(id)를 통해 해당 id의 video를 찾을 수 있다.
Video.findOne()은 () 안에 filter을 통해서 video를 찾을 수 있다.

Video.exists()

video.exists()를 통해 해당 video가 있는지 없는지 true, false 형태로 반환해준다.
() 안에는 filter을 넣어서 원하는 검색 조건을 지정할 수 있다.

3. video validation failed
Video.js schema부분에서 description의 minLength를 20 -> 2로 수정하니까 에러가 발생했다
20으로 다시 되돌리니까 에러가 해결되었음

4. req.flash() requires sessions
logout을 하면 flash오류가 발생하고 새로고침하면 괜찮아지지만 찾다보니 해결방법이 있어서 적용했다
[userController.js]

export const logout = (req, res) => {
  req.session.user = null;
  req.session.loggedIn = false;
  req.flash("info", "Bye Bye");
  return res.redirect("/");
};

[아직 발생하는 오류]

  1. 사용자 로그인 이미지가 없을 때 : 댓글을 입력하고 새로고침을 하면 Interner server Error발생
  2. 댓글을 입력할 때 스페이스바를 누르면 영상도 같이 재생됨

[다른분들의 아이디어]

  • 댓글 편집기능
  • 해시태그로 검색하면 그에맞는 영상 찾아주는 기능
  • 댓글의 총 갯수 표시
  • 카카오, 구글 로그인 (네이버는 까다롭다고 합니다)

[후기]
예습을 미리해서 마지막 일주일이 부족하지 않을거라고 생각했는데 에러가 날때마다 멘탈이 많이 무너져서 힘들었고.. 무사히 배포한걸로 우선 만족이다
백앤드 부분의 강의를 들은지 너무 오래된 상태라 강의텀을 오래쉬면 안된다고 생각했고
유튭 클론코딩을 한번 듣고나니 그래도 전체적인 구조가 이해되고 재밌게 진행할 수 있었다!!

0개의 댓글