Türkçe çeviri özelliği eklendi (GLM 4.6 ile çeviri yapılıyor)
This commit is contained in:
@@ -9,7 +9,12 @@ import { promises as fs } from 'fs';
|
||||
import { v4 as uuidV4 } from 'uuid';
|
||||
import Epub from 'epub-gen';
|
||||
|
||||
const requiredEnv = ['SUPABASE_URL', 'SUPABASE_SERVICE_ROLE_KEY', 'JWT_SECRET'];
|
||||
const requiredEnv = [
|
||||
'SUPABASE_URL',
|
||||
'SUPABASE_SERVICE_ROLE_KEY',
|
||||
'JWT_SECRET',
|
||||
'ZAI_GLM_API_KEY',
|
||||
];
|
||||
requiredEnv.forEach((key) => {
|
||||
if (!process.env[key]) {
|
||||
console.error(`Missing required environment variable: ${key}`);
|
||||
@@ -25,6 +30,7 @@ const allowedOrigins = ORIGIN.split(',').map((origin) => origin.trim());
|
||||
const USERS_TABLE = process.env.SUPABASE_USERS_TABLE || 'users';
|
||||
const JWT_SECRET = process.env.JWT_SECRET;
|
||||
import { supabase } from './src/services/supabaseClient.js';
|
||||
import { translateWithGlm } from './src/services/glmClient.js';
|
||||
|
||||
app.use(
|
||||
cors({
|
||||
@@ -248,6 +254,21 @@ authRouter.post('/forgot-password', async (req, res) => {
|
||||
|
||||
app.use('/auth', authRouter);
|
||||
|
||||
app.post('/translate', async (req, res) => {
|
||||
const { text } = req.body || {};
|
||||
if (!text || !text.trim()) {
|
||||
return res.status(400).json({ message: 'Çevrilecek metin bulunamadı.' });
|
||||
}
|
||||
|
||||
try {
|
||||
const translated = await translateWithGlm(text);
|
||||
return res.json({ text: translated });
|
||||
} catch (error) {
|
||||
console.error('GLM çeviri hatası:', error);
|
||||
return res.status(500).json({ message: error.message || 'Çeviri tamamlanamadı.' });
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/generate-epub', async (req, res) => {
|
||||
const { text, meta, cover } = req.body || {};
|
||||
if (!text || !text.trim()) {
|
||||
|
||||
Reference in New Issue
Block a user