|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 * as uuid from 'uuid'; |
|
|
|
import { Database } from './database/database.js' |
|
import { Readable } from "stream"; |
|
import randomBytes } from "crypto"; |
|
|
|
import { |
|
CheckMilWare, |
|
authenticateApiKey, |
|
apiLimiter |
|
} from './middleware/midware.js'; |
|
|
|
import { setup, serve } from './swagger.js'; |
|
import { swaggerOptions } from './settingOptions.js'; |
|
import path from "path"; |
|
import sharp from "sharp"; |
|
import cors from 'cors'; |
|
import bodyParser from 'body-parser'; |
|
import swaggerJsDoc from 'swagger-jsdoc'; |
|
|
|
|
|
import { GempaRoutes } from './plugins/gempa.js'; |
|
import { FluxRoutes } from './plugins/fluxai.js'; |
|
import { GptRoutes } from './plugins/gptold.js'; |
|
import { HentaiRoutes } from './plugins/hentai.js'; |
|
import { TebakRoutes } from './plugins/tebak.js'; |
|
import { CopilotRoutes } from './plugins/copilot.js'; |
|
import { CarbonRoutes } from './plugins/carbon.js'; |
|
import { UnblockIpRoutes } from './plugins/unblockip.js'; |
|
import { GeminiRoutes } from './routes/googleGemini.js'; |
|
|
|
const __dirname = path.resolve(); |
|
const CheckMilWares = new CheckMilWare(); |
|
const myUUID = uuid.v4(); |
|
|
|
function generateAkenoKey() { |
|
const randomString = randomBytes(24).toString("base64").replace(/[^a-zA-Z0-9]/g, ""); |
|
return `akeno_${randomString}`; |
|
} |
|
|
|
app.disable("x-powered-by"); |
|
app.disable("link") |
|
app.use(cors({ |
|
origin: '*', |
|
methods: ['GET', 'POST'], |
|
allowedHeaders: ['Content-Type', 'Authorization'] |
|
})); |
|
|
|
app.use(bodyParser.json()); |
|
app.use( |
|
bodyParser.urlencoded({ |
|
extended: true, |
|
}) |
|
); |
|
|
|
app.use(express.static('public')); |
|
|
|
app.post('/generate-key', async (req, res) => { |
|
const dbClient = new Database("AkenoXJs", "FastJsAPI"); |
|
const collection = dbClient.collection('api_keys'); |
|
try { |
|
const newKey = generateAkenoKey(); |
|
await collection.insertOne({ |
|
key: newKey, |
|
createdAt: new Date(), |
|
owner: '[email protected]' |
|
}); |
|
res.json({ apiKey: newKey }); |
|
} catch (err) { |
|
res.status(500).json({ error: `Key generation failed: ${err.message}` }); |
|
} |
|
}); |
|
|
|
app.get('/protected', authenticateApiKey, apiLimiter, (req, res) => { |
|
res.json({ message: 'Authorized access!' }); |
|
}); |
|
|
|
app.get("/policy", ( req, res ) => { |
|
res.sendFile(path.join(__dirname + "/public/policy.html")); |
|
}); |
|
|
|
app.get("/scraper/read", ( req, res ) => { |
|
res.sendFile(path.join(__dirname + "/public/docs.html")); |
|
}); |
|
|
|
app.use(async (req, res, next) => { |
|
await CheckMilWares.handle(req, res, next); |
|
}); |
|
|
|
|
|
app.use(GeminiRoutes); |
|
app.use(FluxRoutes); |
|
app.use(GptRoutes); |
|
app.use(HentaiRoutes); |
|
app.use(TebakRoutes); |
|
app.use(GempaRoutes); |
|
app.use(CopilotRoutes); |
|
app.use(UnblockIpRoutes); |
|
app.use(CarbonRoutes); |
|
|
|
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'); |
|
}); |
|
|
|
lifestyle.startServer(app); |