Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const accessTokenOption = {
sameSite: 'None',
maxAge: 1000 * 60 * 60 * 3,
path: '/',
domain: '.sjcpop.com',
// domain: '.sjcpop.com',
};

const refreshTokenOption = {
Expand All @@ -13,7 +13,7 @@ const refreshTokenOption = {
sameSite: 'None',
maxAge: 1000 * 60 * 60 * 24 * 7,
path: '/',
domain: '.sjcpop.com',
// domain: '.sjcpop.com',
};

const clearAccessTokenOption = {
Expand Down
20 changes: 10 additions & 10 deletions config/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ import dotenv from 'dotenv';

dotenv.config();

const client = createClient({
// username: process.env.REDIS_NAME,
// password: process.env.REDIS_SECRET,
socket: {
host: '10.178.0.2',
port: 6379,
},
// legacyMode: true,
});
// const client = createClient({
// // username: process.env.REDIS_NAME,
// // password: process.env.REDIS_SECRET,
// socket: {
// host: '127.0.0.1',
// host: '10.178.0.2',
// port: 6379,
// },
// // legacyMode: true,
// });
const client = createClient({
// username: process.env.REDIS_NAME,
// password: process.env.REDIS_SECRET,
socket: {
host: '127.0.0.1',
port: 6379,
},
// legacyMode: true,
});

client.on('error', (err) => console.log('Redis Client Error', err));

Expand Down
24 changes: 12 additions & 12 deletions repositorys/followRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const getFollowers = async (userId, targetUserId, size, cursor, name) => {
const whereCondition = {
following_id: targetUserId,
...(name && {
following: {
follower: {
nickname: { contains: name, mode: 'insensitive' },
},
}),
Expand All @@ -20,7 +20,7 @@ const getFollowers = async (userId, targetUserId, size, cursor, name) => {
take: size,
skip: cursor,
include: {
following: {
follower: {
select: {
id: true,
email: true,
Expand All @@ -32,7 +32,7 @@ const getFollowers = async (userId, targetUserId, size, cursor, name) => {
});

// 모든 관계를 한 번에 가져오기
const followerIds = followers.map((f) => f.following.id);
const followerIds = followers.map((f) => f.follower.id);
const [followingRelations, followerRelations] = await Promise.all([
prisma.follow.findMany({
where: {
Expand All @@ -49,12 +49,12 @@ const getFollowers = async (userId, targetUserId, size, cursor, name) => {
]);

const followersWithStatus = followers.map((follower) => {
const { profile_image, ...rest } = follower.following;
const { profile_image, ...rest } = follower.follower;
const isFollowing = followingRelations.some(
(rel) => rel.following_id === follower.following.id
(rel) => rel.following_id === follower.follower.id
);
const isFollower = followerRelations.some(
(rel) => rel.follower_id === follower.following.id
(rel) => rel.follower_id === follower.follower.id
);

return {
Expand All @@ -80,7 +80,7 @@ const getFollowing = async (userId, targetUserId, size, cursor, name) => {
const whereCondition = {
follower_id: targetUserId,
...(name && {
follower: {
following: {
nickname: { contains: name, mode: 'insensitive' },
},
}),
Expand All @@ -93,7 +93,7 @@ const getFollowing = async (userId, targetUserId, size, cursor, name) => {
take: size,
skip: cursor,
include: {
follower: {
following: {
select: {
id: true,
email: true,
Expand All @@ -105,7 +105,7 @@ const getFollowing = async (userId, targetUserId, size, cursor, name) => {
});

// 모든 관계를 한 번에 가져오기
const followingIds = following.map((f) => f.follower.id);
const followingIds = following.map((f) => f.following.id);
const [followingRelations, followerRelations] = await Promise.all([
prisma.follow.findMany({
where: {
Expand All @@ -122,12 +122,12 @@ const getFollowing = async (userId, targetUserId, size, cursor, name) => {
]);

const followingWithStatus = following.map((item) => {
const { profile_image, ...rest } = item.follower;
const { profile_image, ...rest } = item.following;
const isFollowing = followingRelations.some(
(rel) => rel.following_id === item.follower.id
(rel) => rel.following_id === item.following.id
);
const isFollower = followerRelations.some(
(rel) => rel.follower_id === item.follower.id
(rel) => rel.follower_id === item.following.id
);

return {
Expand Down
Loading