|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import express from 'express'; |
|
const app = express(); |
|
|
|
import * as swaggerUi from 'swagger-ui-express'; |
|
import * as cheerio from 'cheerio'; |
|
import * as lifestyle from './startup/lifestyle.js'; |
|
|
|
import { Readable } from "stream"; |
|
import { OpenaiRes, tebakgambar, AnimeHentai } from './scrapper.js'; |
|
import { CheckMilWare } from './middleware/midware.js'; |
|
import { setup, serve } from './swagger.js'; |
|
|
|
import sharp from "sharp"; |
|
import cors from 'cors'; |
|
import bodyParser from 'body-parser'; |
|
import swaggerJsDoc from 'swagger-jsdoc'; |
|
|
|
|
|
import { FluxRoutes } from './plugins/fluxai.js'; |
|
import { GeminiRoutes } from './routes/googleGemini.js'; |
|
|
|
const CheckMilWares = new CheckMilWare(); |
|
|
|
app.disable('x-powered-by'); |
|
app.use(cors({ |
|
origin: '*', |
|
methods: ['GET', 'POST'], |
|
allowedHeaders: ['Content-Type', 'Authorization'] |
|
})); |
|
app.use(bodyParser.json()); |
|
app.use( |
|
bodyParser.urlencoded({ |
|
extended: true, |
|
}) |
|
); |
|
|
|
|
|
app.use(GeminiRoutes); |
|
app.use(FluxRoutes); |
|
|
|
const swaggerOptions = { |
|
definition: { |
|
openapi: '3.0.0', |
|
info: { |
|
title: 'AkenoXJs', |
|
version: '1.0.0', |
|
description: "Free API by @xtdevs", |
|
contact: { |
|
name: "RandyDev", |
|
url: "", |
|
email: "" |
|
}, |
|
license: { |
|
name: "MIT LICENSE", |
|
url: "https://github.com/xtsea/x-api-js/blob/main/LICENSE" |
|
} |
|
}, |
|
servers: [ |
|
{ |
|
url: 'https://randydev-ryu-js.hf.space', |
|
description: 'url' |
|
} |
|
], |
|
tags: [ |
|
{ name: "AI" } |
|
] |
|
}, |
|
apis: [ |
|
"./routes/*.js", |
|
"./plugins/*.js", |
|
"./routes/*.route.js" |
|
] |
|
}; |
|
|
|
const specs = swaggerJsDoc(swaggerOptions); |
|
|
|
app.use( |
|
'/docs', |
|
serve, |
|
setup(specs, { |
|
customCss: ` |
|
.swagger-ui .topbar { display: none; } |
|
.swagger-ui .opblock .opblock-summary-path { |
|
display: inline-block; |
|
word-break: break-word; |
|
white-space: nowrap; |
|
overflow: hidden; |
|
text-overflow: ellipsis; |
|
max-width: 100%; |
|
} |
|
`, |
|
customCssUrl: "https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/4.3.0/swagger-ui.min.css", |
|
customSiteTitle: 'AkenoXJs' |
|
}) |
|
); |
|
|
|
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/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 }); |
|
} |
|
}); |
|
|
|
lifestyle.startServer(app); |