Build fixes: offline-safe fonts, Next.js API route type updates, TS strict errors resolved, MUI import cleanup, chat markdown wrapper, Azure OpenAI typing, caching key + chapter API id types, and misc error-logging typings.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { NextResponse } from 'next/server'
|
||||
import { z } from 'zod'
|
||||
import { PrismaClient } from '@prisma/client'
|
||||
import { verifyToken } from '@/lib/auth'
|
||||
@@ -14,8 +14,8 @@ const updateConversationSchema = z.object({
|
||||
|
||||
// GET /api/chat/conversations/[id] - Get conversation with messages
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
request: Request,
|
||||
{ params }: any
|
||||
) {
|
||||
try {
|
||||
// Get user from authentication
|
||||
@@ -28,7 +28,7 @@ export async function GET(
|
||||
}
|
||||
|
||||
const token = authHeader.substring(7)
|
||||
const payload = verifyToken(token)
|
||||
const payload = await verifyToken(token)
|
||||
|
||||
if (!payload) {
|
||||
return NextResponse.json(
|
||||
@@ -100,8 +100,8 @@ export async function GET(
|
||||
|
||||
// PUT /api/chat/conversations/[id] - Update conversation
|
||||
export async function PUT(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
request: Request,
|
||||
{ params }: any
|
||||
) {
|
||||
try {
|
||||
// Get user from authentication
|
||||
@@ -114,7 +114,7 @@ export async function PUT(
|
||||
}
|
||||
|
||||
const token = authHeader.substring(7)
|
||||
const payload = verifyToken(token)
|
||||
const payload = await verifyToken(token)
|
||||
|
||||
if (!payload) {
|
||||
return NextResponse.json(
|
||||
@@ -198,8 +198,8 @@ export async function PUT(
|
||||
|
||||
// DELETE /api/chat/conversations/[id] - Delete conversation
|
||||
export async function DELETE(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
request: Request,
|
||||
{ params }: any
|
||||
) {
|
||||
try {
|
||||
// Get user from authentication
|
||||
@@ -212,7 +212,7 @@ export async function DELETE(
|
||||
}
|
||||
|
||||
const token = authHeader.substring(7)
|
||||
const payload = verifyToken(token)
|
||||
const payload = await verifyToken(token)
|
||||
|
||||
if (!payload) {
|
||||
return NextResponse.json(
|
||||
@@ -263,4 +263,4 @@ export async function DELETE(
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { NextResponse } from 'next/server'
|
||||
import { z } from 'zod'
|
||||
import { PrismaClient } from '@prisma/client'
|
||||
import { verifyToken } from '@/lib/auth'
|
||||
@@ -19,7 +19,7 @@ const getConversationsSchema = z.object({
|
||||
})
|
||||
|
||||
// GET /api/chat/conversations - List user's conversations
|
||||
export async function GET(request: NextRequest) {
|
||||
export async function GET(request: Request) {
|
||||
try {
|
||||
// Get user from authentication
|
||||
const authHeader = request.headers.get('authorization')
|
||||
@@ -31,7 +31,7 @@ export async function GET(request: NextRequest) {
|
||||
}
|
||||
|
||||
const token = authHeader.substring(7)
|
||||
const payload = verifyToken(token)
|
||||
const payload = await verifyToken(token)
|
||||
|
||||
if (!payload) {
|
||||
return NextResponse.json(
|
||||
@@ -130,7 +130,7 @@ export async function GET(request: NextRequest) {
|
||||
}
|
||||
|
||||
// POST /api/chat/conversations - Create new conversation
|
||||
export async function POST(request: NextRequest) {
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
// Get user from authentication
|
||||
const authHeader = request.headers.get('authorization')
|
||||
@@ -142,7 +142,7 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
|
||||
const token = authHeader.substring(7)
|
||||
const payload = verifyToken(token)
|
||||
const payload = await verifyToken(token)
|
||||
|
||||
if (!payload) {
|
||||
return NextResponse.json(
|
||||
@@ -207,4 +207,4 @@ export async function POST(request: NextRequest) {
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { NextResponse } from 'next/server'
|
||||
import { z } from 'zod'
|
||||
import { PrismaClient, ChatMessageRole } from '@prisma/client'
|
||||
import { searchBibleHybrid, BibleVerse } from '@/lib/vector-search'
|
||||
@@ -21,7 +21,7 @@ const chatRequestSchema = z.object({
|
||||
})).optional().default([])
|
||||
})
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const body = await request.json()
|
||||
const { message, conversationId, locale, history } = chatRequestSchema.parse(body)
|
||||
@@ -40,7 +40,7 @@ export async function POST(request: NextRequest) {
|
||||
console.log('Chat API - userId extracted from token:', userId)
|
||||
} catch (error) {
|
||||
// Continue without authentication for backward compatibility
|
||||
console.log('Chat API - authentication failed:', error.message)
|
||||
console.log('Chat API - authentication failed:', (error as any)?.message || error)
|
||||
}
|
||||
} else {
|
||||
console.log('Chat API - no valid auth header')
|
||||
@@ -335,7 +335,7 @@ function calculateMessageRelevance(message: any, currentMessage: string, locale:
|
||||
const messageWords = msgContent.split(/\s+/)
|
||||
|
||||
for (const word of currentWords) {
|
||||
if (messageWords.some(mWord => mWord.includes(word) || word.includes(mWord))) {
|
||||
if (messageWords.some((mWord: string) => mWord.includes(word) || word.includes(mWord))) {
|
||||
score += 0.2
|
||||
}
|
||||
}
|
||||
@@ -401,7 +401,7 @@ function summarizeMessage(message: any): string {
|
||||
if (content.length <= 100) return content
|
||||
|
||||
// Extract key points and questions
|
||||
const sentences = content.split(/[.!?]+/).filter(s => s.trim().length > 10)
|
||||
const sentences = content.split(/[.!?]+/).filter((s: string) => s.trim().length > 10)
|
||||
if (sentences.length <= 2) return content
|
||||
|
||||
// Keep first and last sentence, or most important parts
|
||||
|
||||
Reference in New Issue
Block a user