kimsungmin2 / node.js3

0 stars 0 forks source link

Feedback #1

Open bewisesh91 opened 4 months ago

bewisesh91 commented 4 months ago

필수 요구 사항

개발

동작 확인

배포

피드백

대부분의 필수 요구 사항과 선택 요구 사항을 잘 구현하였습니다. 다만, Redis나 Slack 같은 경우, 어디서 사용되는 것인지 제가 파악이 잘 안되는데 혹시 다시 알려주실 수 있으실까요? Redis에 토큰을 저장하는 부분이 제가 확인이 안되어서요. 또한, 슬로우 쿼리에 대해서 슬랙 알람 보내는 부분 역시, 슬랙 관련한 것이 있기는 한 것 같은데 어디서 사용되는지 정확히 파악이 되지 않습니다. 위 두 부분 빼고는 정말 잘 구현하셨어요! 고생하셨습니다.

kimsungmin2 commented 4 months ago

` getResumes = async (orderKey, orderValue) => {

    const delay = () => {
        return new Promise((resolve) => setTimeout(resolve, Math.floor(Math.random() * 6) * 1000));
    };

    await delay();

    let orderBy = {};
    if (orderBy) {
        orderBy[orderKey] = orderValue && orderValue.toUpperCase() === "ASC" ? "asc" : "desc";
    } else {
        orderBy = { createdAt: "desc" };
    }

    const resumes = await this.resumesRepository.getResumes(orderBy);

    await sendTodayData();

    return resumes;
};`

여기서 슬랙 알림을 sendTodayData 미들웨어로 빼서 사용하고 있습니다! 시간은 단위 테스트에서 타임아웃 뜨는건 다 2초로 줄였고 나머진 3초로 설정 해뒀습니다! 따로 콘솔을 찍어놓지는 못해서 죄송합니다 ㅜ

kimsungmin2 commented 4 months ago

` signIn = async (email, password) => { const user = await this.usersRepository.getUserByEmail(email); if (!user) { throw new Error("존재하지 않는 이메일입니다."); }

    const checkpass = await bcrypt.compare(password, user.password);
    if (!checkpass) {
        throw new Error("비밀번호가 일치하지 않습니다.");
    }

    if (user.emailstatus !== "yes") return res.status(401).json({ message: "가입 대기중인 계정입니다." });
    const userJWT = jwt.sign({ userId: user.userId }, process.env.JWT_SECRET, { expiresIn: "12h" });
    const refreshToken = jwt.sign({ userId: user.userId }, process.env.REFRESH_SECRET, { expiresIn: "7d" });

    await this.usersRepository.saveToken(user.userId, refreshToken);

    return { userJWT, refreshToken };
};`

서비스 계층에서 레포에 만들어둔 변수를 이용해서 레디스에 따로 저장하고 있습니다

saveToken = async (userId, refreshToken) => { const tokens = await this.redisClient.hSet(tokenKey(userId), "token", refreshToken); return tokens;

스크린샷 2024-02-23 오전 1 41 47