commit 93b8fd9d8060b0200ad20a281598cb45786c92a0 Author: wowlikon Date: Thu Oct 2 12:32:57 2025 +0000 init diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..87c61e5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM node:20-alpine + +WORKDIR /app +COPY package*.json ./ +RUN npm install --only=production +COPY server.js config.json ./ + +EXPOSE 3000 +CMD ["node", "server.js"] + diff --git a/README.md b/README.md new file mode 100644 index 0000000..ad2cfb4 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# AniX Share + +Сервис для создания ссылки на аниме/профиль/коллекцию в AniX/Anixart. +Все настройки находятся в `config.json`. Для запуска используется docker. + diff --git a/config.json b/config.json new file mode 100644 index 0000000..ff4a105 --- /dev/null +++ b/config.json @@ -0,0 +1,12 @@ +{ + "port": 3000, + "targetUrl": "https://anix.0x174.su", + "auth": { + "username": "anime", + "password": "just_watch" + }, + "redirectDelay": 3000, + "timeout": 5000, + "userAgent": "MetaFetcherBot/1.0" +} + diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..8e9bed9 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "anix-share", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "anix-share", + "version": "1.0.0", + "license": "MIT" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..fb6cb19 --- /dev/null +++ b/package.json @@ -0,0 +1,24 @@ +{ + "name": "anix-share", + "version": "1.0.0", + "description": "", + "main": "server.js", + "dependencies": { + "express": "^4.19.0", + "axios": "^1.7.0", + "cheerio": "^1.0.0" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "start": "node server.js" + }, + "repository": { + "type": "git", + "url": "git.0x174.su/wowlikon/anix-share" + }, + "keywords": [ + "anix" + ], + "author": "wowlikon", + "license": "MIT" +} diff --git a/server.js b/server.js new file mode 100644 index 0000000..707b3a9 --- /dev/null +++ b/server.js @@ -0,0 +1,51 @@ +import express from 'express'; +import axios from 'axios'; +import * as cheerio from 'cheerio'; +import fs from 'fs'; + +const config = JSON.parse(fs.readFileSync('./config.json', 'utf-8')); +const { port, targetUrl, auth, redirectDelay, timeout, userAgent } = config; + +const app = express(); + +app.get('*', async (req, res) => { + try { + const path = req.path === '/' ? '' : req.path; + const fullUrl = new URL(path, targetUrl).toString(); + const response = await axios.get(fullUrl, { + auth, timeout, + headers: {'User-Agent': userAgent} + }); + + const $ = cheerio.load(response.data); + const metas = []; + $('meta').each((_, el) => {metas.push(el.attribs);}); + + res.send(` + + + + + Meta Redirect + ${metas.map(m => ` `${k}="${v}"`).join(' ')}>`).join('\n')} + + + +

Anix

+

Редирект через ${redirectDelay / 1000} сек на ${fullUrl}

+ + + `); + } catch (err) { + console.error('Ошибка:', err.message); + res.status(500).send(`

Ошибка при загрузке ${req.path}

${err.message}
`); + } +}); + +app.listen(port, () => { + console.log(`🚀 Сервер запущен: http://localhost:${port}`); + console.log(`🔗 Пример: http://localhost:${port}/news`); +}); +