|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import express from 'express'; |
|
const app = express(); |
|
|
|
import * as swaggerUi from 'swagger-ui-express'; |
|
import * as swaggerDocs from './swagger.js'; |
|
import * as cheerio from 'cheerio'; |
|
import * as lifestyle from './lifestyle.js'; |
|
|
|
import sharp from "sharp"; |
|
import { Readable } from "stream"; |
|
import { schellwithflux } from './fluxai.js'; |
|
import { OpenaiRes, tebakgambar, AnimeHentai } from './scrapper.js'; |
|
import { GeminiResponse } from './googleGemini.js'; |
|
import { CheckMilWare } from './midware.js'; |
|
|
|
const CheckMilWares = new CheckMilWare(); |
|
|
|
app.disable('x-powered-by'); |
|
|
|
app.get('/', (req, res) => { |
|
res.redirect('https://t.me/RendyProjects'); |
|
}); |
|
|
|
app.use(async (req, res, next) => { |
|
await CheckMilWares.handle(req, res, next); |
|
}); |
|
|
|
app.get('/api/v1/hentai-anime', async (req, res) => { |
|
try { |
|
const result = await AnimeHentai(); |
|
if (result) { |
|
res.json({ result }); |
|
} else { |
|
res.status(404).json({ error: "No result found." }); |
|
} |
|
} catch (error) { |
|
res.status(500).json({ error: error.message }); |
|
} |
|
}); |
|
|
|
app.get("/api/v1/google-gemini", async (req, res) => { |
|
try { |
|
const query = req.query.query; |
|
const results = await GeminiResponse(query); |
|
res.json({ message: results }); |
|
} catch (e) { |
|
res.status(500).json({ error: e.message }); |
|
} |
|
}); |
|
|
|
app.get('/api/v1/tebakgambar', async (req, res) => { |
|
try { |
|
const result = await tebakgambar(); |
|
if (result) { |
|
res.json({ result }); |
|
} else { |
|
res.status(404).json({ error: "No result found." }); |
|
} |
|
} catch (error) { |
|
res.status(500).json({ error: error.message }); |
|
} |
|
}); |
|
|
|
app.get('/api/v1/gpt-old', async (req, res) => { |
|
try { |
|
const query = req.query.query; |
|
const results = await OpenaiRes(query); |
|
res.json({ results }); |
|
} catch (error) { |
|
res.status(401).json({ error: error.message }); |
|
} |
|
}); |
|
|
|
app.post("/api/v1/fluxai-ai", async (req, res) => { |
|
try { |
|
const query = req.body.query; |
|
const imageBytes = await schellwithflux(query); |
|
|
|
if (!imageBytes) { |
|
return res.status(500).json({ error: "Failed to fetch image bytes" }); |
|
} |
|
const processedImage = await sharp(imageBytes) |
|
.jpeg() |
|
.toBuffer(); |
|
res.set("Content-Type", "image/jpeg"); |
|
const stream = Readable.from(processedImage); |
|
stream.pipe(res); |
|
} catch (error) { |
|
console.error("Error processing image:", error.message); |
|
res.status(500).json({ error: "Internal server error" }); |
|
} |
|
}); |
|
|
|
lifestyle.startServer(app); |