fix: resolve multiple runtime and build issues
- Fix network binding to allow external access (0.0.0.0) - Upgrade to Node.js 20.x for Next.js 16 compatibility - Fix next-auth v4 configuration and session handling - Add Steam client secret for Steam OAuth provider - Fix Prisma schema unique constraint syntax - Fix database creation script for automated deployment - Fix game search API to use new IStoreService endpoint - Fix session auth in API routes for Steam linking - Add TypeScript types for next-auth session
This commit is contained in:
@@ -30,29 +30,29 @@ export async function POST(
|
||||
const existingVote = await prisma.vote.findUnique({
|
||||
where: {
|
||||
user_review_unique: {
|
||||
user_id: session.user.id,
|
||||
review_id: resolvedParams.id
|
||||
userId: session.user.id,
|
||||
reviewId: resolvedParams.id
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (existingVote) {
|
||||
if (existingVote.vote_type === voteType) {
|
||||
if (existingVote.voteType === voteType) {
|
||||
await prisma.vote.delete({
|
||||
where: { id: existingVote.id }
|
||||
})
|
||||
} else {
|
||||
await prisma.vote.update({
|
||||
where: { id: existingVote.id },
|
||||
data: { vote_type: voteType }
|
||||
data: { voteType: voteType }
|
||||
})
|
||||
}
|
||||
} else {
|
||||
await prisma.vote.create({
|
||||
data: {
|
||||
user_id: session.user.id,
|
||||
review_id: resolvedParams.id,
|
||||
vote_type: voteType
|
||||
userId: session.user.id,
|
||||
reviewId: resolvedParams.id,
|
||||
voteType: voteType
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ export async function GET(request: NextRequest) {
|
||||
const where: Record<string, unknown> = {}
|
||||
|
||||
if (appId) {
|
||||
where.app_id = parseInt(appId)
|
||||
where.appId = parseInt(appId)
|
||||
}
|
||||
|
||||
const reviews = await prisma.review.findMany({
|
||||
@@ -34,16 +34,16 @@ export async function GET(request: NextRequest) {
|
||||
}
|
||||
},
|
||||
orderBy: {
|
||||
created_at: 'desc'
|
||||
createdAt: 'desc'
|
||||
},
|
||||
take: limit
|
||||
})
|
||||
|
||||
const formattedReviews = reviews.map(review => {
|
||||
const upvotes = review.votes.filter(v => v.vote_type === 1).length
|
||||
const downvotes = review.votes.filter(v => v.vote_type === -1).length
|
||||
const formattedReviews = reviews.map((review: any) => {
|
||||
const upvotes = review.votes.filter((v: any) => v.voteType === 1).length
|
||||
const downvotes = review.votes.filter((v: any) => v.voteType === -1).length
|
||||
const userVote = userId
|
||||
? review.votes.find(v => v.user_id === userId)?.vote_type || null
|
||||
? review.votes.find((v: any) => v.userId === userId)?.voteType || null
|
||||
: null
|
||||
|
||||
return {
|
||||
@@ -52,11 +52,11 @@ export async function GET(request: NextRequest) {
|
||||
avatar_url: review.user.steamAvatar,
|
||||
content: review.content,
|
||||
rating: review.rating,
|
||||
playtime_hours: review.playtime_hours,
|
||||
playtime_hours: review.playtimeHours,
|
||||
upvotes,
|
||||
downvotes,
|
||||
user_vote: userVote,
|
||||
created_at: review.created_at.toISOString(),
|
||||
created_at: review.createdAt.toISOString(),
|
||||
game_name: review.game?.name
|
||||
}
|
||||
})
|
||||
@@ -89,8 +89,8 @@ export async function POST(request: NextRequest) {
|
||||
|
||||
const existingReview = await prisma.review.findFirst({
|
||||
where: {
|
||||
user_id: session.user.id,
|
||||
app_id: appId
|
||||
userId: session.user.id,
|
||||
appId: appId
|
||||
}
|
||||
})
|
||||
|
||||
@@ -102,16 +102,16 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
|
||||
const game = await prisma.game.findUnique({
|
||||
where: { app_id: appId }
|
||||
where: { appId: appId }
|
||||
})
|
||||
|
||||
const review = await prisma.review.create({
|
||||
data: {
|
||||
user_id: session.user.id,
|
||||
app_id: appId,
|
||||
userId: session.user.id,
|
||||
appId: appId,
|
||||
content,
|
||||
rating,
|
||||
playtime_hours: playtimeHours || null
|
||||
playtimeHours: playtimeHours || null
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user