@shun-js/aitubiao-server 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 qiaowenbin<uikoo9@qq.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/app.js ADDED
@@ -0,0 +1,42 @@
1
+ // config
2
+ const { parseServerConfig } = require('@shun-js/shun-config');
3
+
4
+ // init
5
+ (async () => {
6
+ // config
7
+ const config = await parseServerConfig(process.argv);
8
+ if (!config) {
9
+ console.log('read server config fail');
10
+ return;
11
+ }
12
+
13
+ // options
14
+ const options = {};
15
+
16
+ // options cros
17
+ options.cros = true;
18
+
19
+ // options config
20
+ options.config = config;
21
+
22
+ // options.redis
23
+ options.redis = require('qiao-redis');
24
+ options.redisOptions = config.redisOptions;
25
+
26
+ // options log
27
+ options.log = require('qiao-log');
28
+ options.logOptions = require('./server/log-options.js')();
29
+
30
+ // options rate limit
31
+ options.rateLimitLib = require('qiao-rate-limit');
32
+ options.rateLimitOptions = config.rateLimitOptions;
33
+
34
+ // options checks
35
+ options.checks = [require('./server/util/check.js').checkUserAuth];
36
+
37
+ // options modules
38
+ options.modules = [require('qiao-z-sms').init, require('qiao-z-nuser').init];
39
+
40
+ const app = await require('qiao-z')(options);
41
+ app.listen(config.port);
42
+ })();
@@ -0,0 +1 @@
1
+ 4cb288d7aef5469c92616c0f5b5aeb89
@@ -0,0 +1,4 @@
1
+ User-agent: *
2
+ Allow: /
3
+
4
+ Sitemap: https://aitubiao.online/sitemap.xml
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <urlset
3
+ xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
4
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
+ xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
6
+ http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
7
+
8
+ <url>
9
+ <loc>https://aitubiao.online/</loc>
10
+ <lastmod>2025-09-09</lastmod>
11
+ <changefreq>daily</changefreq>
12
+ <priority>1.0</priority>
13
+ </url>
14
+ </urlset>
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@shun-js/aitubiao-server",
3
+ "version": "0.0.5",
4
+ "description": "aitubiao.online server",
5
+ "keywords": [
6
+ "ai tubiao"
7
+ ],
8
+ "license": "MIT",
9
+ "author": "uikoo9 <uikoo9@qq.com>",
10
+ "homepage": "https://github.com/uikoo9/shun-js",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/uikoo9/shun-js.git"
14
+ },
15
+ "bugs": {
16
+ "url": "https://github.com/uikoo9/shun-js/issues"
17
+ },
18
+ "files": [
19
+ "server",
20
+ "assets",
21
+ "views",
22
+ "app.js"
23
+ ],
24
+ "dependencies": {
25
+ "@shun-js/shun-config": "^0.0.9",
26
+ "@shun-js/shun-service": "^0.1.0",
27
+ "qiao-agent": "^0.2.5",
28
+ "qiao-file": "^5.0.1",
29
+ "qiao-log": "^5.1.9",
30
+ "qiao-rate-limit": "^5.8.8",
31
+ "qiao-redis": "^5.8.9",
32
+ "qiao-z": "^5.8.9",
33
+ "qiao-z-nuser": "^5.8.8",
34
+ "qiao-z-service": "^5.8.8",
35
+ "qiao-z-sms": "^5.8.8"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public",
39
+ "registry": "https://registry.npmjs.org/"
40
+ },
41
+ "gitHead": "5ea579e7896eb30f9175b967eea0d3a17fdd2e68"
42
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * log options
3
+ * @returns
4
+ */
5
+ module.exports = () => {
6
+ // log options
7
+ const logLevel = 'debug';
8
+ const logPattern = 'yyyy-MM-dd-hh';
9
+ const logPath = require('path').resolve(__dirname, '../logs/qiao-z.log');
10
+
11
+ return {
12
+ pm2: true,
13
+ pm2InstanceVar: 'INSTANCE_ID',
14
+ appenders: {
15
+ stdout: {
16
+ type: 'stdout',
17
+ },
18
+ datefile: {
19
+ type: 'dateFile',
20
+ pattern: logPattern,
21
+ filename: logPath,
22
+ keepFileExt: true,
23
+ numBackups: 30,
24
+ compress: true,
25
+ },
26
+ },
27
+ categories: {
28
+ default: {
29
+ level: logLevel,
30
+ appenders: ['stdout', 'datefile'],
31
+ },
32
+ },
33
+ };
34
+ };
@@ -0,0 +1,17 @@
1
+ // service
2
+ const service = require('../service/IndexService.js');
3
+
4
+ /**
5
+ * controller
6
+ */
7
+ module.exports = (app) => {
8
+ // index
9
+ app.get('/', (req, res) => {
10
+ service.index(req, res);
11
+ });
12
+
13
+ // chart
14
+ app.post('/chart', (req, res) => {
15
+ service.chart(req, res);
16
+ });
17
+ };
@@ -0,0 +1,18 @@
1
+ // service
2
+ const service = require('../service/SEOService.js');
3
+
4
+ /**
5
+ * controller
6
+ */
7
+ module.exports = (app) => {
8
+ // seo
9
+ app.get('/robots.txt', (req, res) => {
10
+ service.robots(req, res);
11
+ });
12
+ app.get('/sitemap.xml', (req, res) => {
13
+ service.sitemap(req, res);
14
+ });
15
+ app.get('/4cb288d7aef5469c92616c0f5b5aeb89.txt', (req, res) => {
16
+ service.bingIndexNow(req, res);
17
+ });
18
+ };
@@ -0,0 +1,70 @@
1
+ // qiao
2
+ const { genChart } = require('qiao-agent');
3
+
4
+ // util
5
+ const { chartFeishuMsg, chartResFeishuMsg, errorFeishuMsg } = require('../../util/feishu.js');
6
+
7
+ /**
8
+ * index
9
+ * @param {*} req
10
+ * @param {*} res
11
+ */
12
+ exports.index = async (req, res) => {
13
+ // const
14
+ const pagePath = './views/index.html';
15
+
16
+ // is static
17
+ const isStatic = await res.staticRender(pagePath);
18
+ if (isStatic) return;
19
+
20
+ // render
21
+ res.render(pagePath, {}, true);
22
+ };
23
+
24
+ /**
25
+ * chart
26
+ * @param {*} req
27
+ * @param {*} res
28
+ * @returns
29
+ */
30
+ exports.chart = async (req, res) => {
31
+ const methodName = 'chart';
32
+
33
+ // check
34
+ if (!req.body.userPrompt) {
35
+ const msg = 'need userPrompt';
36
+ req.logger.error(methodName, msg);
37
+ res.jsonFail(msg);
38
+ return;
39
+ }
40
+
41
+ // const
42
+ const userPrompt = decodeURIComponent(req.body.userPrompt);
43
+ req.logger.info(methodName, 'userPrompt', userPrompt);
44
+ chartFeishuMsg(req);
45
+
46
+ // go
47
+ try {
48
+ const mcpUrl = 'http://172.31.26.31:9201/mcp';
49
+ const chartRes = await genChart(global.QZ_CONFIG.llm, userPrompt, mcpUrl);
50
+ req.logger.info(methodName, 'chartRes', chartRes);
51
+
52
+ // check
53
+ if (!chartRes) {
54
+ const msg = 'chart res is null';
55
+ errorFeishuMsg(req, msg);
56
+ req.logger.error(methodName, msg);
57
+ res.jsonFail(msg);
58
+ return;
59
+ }
60
+
61
+ // r
62
+ chartResFeishuMsg(req, JSON.stringify(chartRes));
63
+ res.jsonSuccess('success', chartRes);
64
+ } catch (error) {
65
+ const msg = 'gen chart error';
66
+ errorFeishuMsg(req, msg);
67
+ req.logger.error(methodName, msg, error);
68
+ res.jsonFail(msg);
69
+ }
70
+ };
@@ -0,0 +1,38 @@
1
+ // path
2
+ const path = require('path');
3
+
4
+ // qiao
5
+ const { readFile } = require('qiao-file');
6
+
7
+ /**
8
+ * robots
9
+ * @param {*} req
10
+ * @param {*} res
11
+ */
12
+ exports.robots = async (req, res) => {
13
+ const txtPath = path.resolve(__dirname, '../../../assets/robots.txt');
14
+ const txt = await readFile(txtPath);
15
+ res.send(txt);
16
+ };
17
+
18
+ /**
19
+ * sitemap
20
+ * @param {*} req
21
+ * @param {*} res
22
+ */
23
+ exports.sitemap = async (req, res) => {
24
+ const sitemapPath = path.resolve(__dirname, '../../../assets/sitemap.xml');
25
+ const sitemap = await readFile(sitemapPath);
26
+ res.send(sitemap);
27
+ };
28
+
29
+ /**
30
+ * bingIndexNow
31
+ * @param {*} req
32
+ * @param {*} res
33
+ */
34
+ exports.bingIndexNow = async (req, res) => {
35
+ const txtPath = path.resolve(__dirname, '../../../assets/bing.txt');
36
+ const txt = await readFile(txtPath);
37
+ res.send(txt);
38
+ };
@@ -0,0 +1,23 @@
1
+ // qiao
2
+ const { userCheck } = require('qiao-z-service');
3
+
4
+ /**
5
+ * checkUserAuth
6
+ * @param {*} req
7
+ * @param {*} res
8
+ * @returns
9
+ */
10
+ exports.checkUserAuth = async function (req, res) {
11
+ const userCheckRes = await userCheck(global.QZ_CONFIG.user, {
12
+ userid: req.headers.userid,
13
+ usertoken: req.headers.usertoken,
14
+ paths: JSON.stringify(global.QZ_CONFIG.paths),
15
+ path: req.url.pathname,
16
+ });
17
+
18
+ // pass
19
+ if (userCheckRes && userCheckRes.type === 'success') return true;
20
+
21
+ // r
22
+ res.json(userCheckRes);
23
+ };
@@ -0,0 +1,79 @@
1
+ // feishu
2
+ const { sendMsgToFeishu } = require('qiao-z-service');
3
+
4
+ /**
5
+ * feishuMsg
6
+ * @param {*} msg
7
+ */
8
+ exports.feishuMsg = (msg) => {
9
+ if (global.QZ_CONFIG.env !== 'production') return;
10
+
11
+ sendMsgToFeishu({
12
+ url: global.QZ_CONFIG.feishu.url,
13
+ appId: global.QZ_CONFIG.feishu.appId,
14
+ appKey: global.QZ_CONFIG.feishu.appKey,
15
+ feishuUrl: global.QZ_CONFIG.urls.feishuUrl,
16
+ feishuMsg: msg,
17
+ });
18
+ };
19
+
20
+ // is bot
21
+ function isBot(req) {
22
+ const ua = req.useragent;
23
+ const hasOSName = ua && ua.os && ua.os.name;
24
+ const isGoogleBot = ua && ua.browser && ua.browser.name === 'Googlebot';
25
+ const isMetaBot = ua && ua.browser && ua.browser.name === 'meta-externalagent';
26
+ const isSafariBot = ua && ua.engine && ua.engine.name === 'WebKit' && ua.engine.version === '605.1.15';
27
+ return !hasOSName || isGoogleBot || isMetaBot || isSafariBot;
28
+ }
29
+
30
+ /**
31
+ * errorFeishuMsg
32
+ * @param {*} req
33
+ * @param {*} msg
34
+ * @returns
35
+ */
36
+ exports.errorFeishuMsg = (req, msg) => {
37
+ // check
38
+ if (isBot(req)) return;
39
+
40
+ // msg
41
+ const uaJson = JSON.stringify(req.useragent || {});
42
+ exports.feishuMsg(`【通知】服务异常,${msg},请查看日志,ua:${uaJson}`);
43
+ };
44
+
45
+ /**
46
+ * chartFeishuMsg
47
+ * @param {*} req
48
+ * @returns
49
+ */
50
+ exports.chartFeishuMsg = (req) => {
51
+ // check
52
+ if (isBot(req)) return;
53
+
54
+ // msg
55
+ const uaJson = JSON.stringify(req.useragent || {});
56
+ const userid = req.headers.userid;
57
+ const prompt = req.body.userPrompt;
58
+
59
+ const msg = `【通知】/chart被访问\nuserid:${userid}\nua:\n${uaJson}\nprompt:\n${prompt}`;
60
+ exports.feishuMsg(msg);
61
+ };
62
+
63
+ /**
64
+ * chartResFeishuMsg
65
+ * @param {*} req
66
+ * @returns
67
+ */
68
+ exports.chartResFeishuMsg = (req, chartRes) => {
69
+ // check
70
+ if (isBot(req)) return;
71
+
72
+ // msg
73
+ const uaJson = JSON.stringify(req.useragent || {});
74
+ const userid = req.headers.userid;
75
+ const prompt = req.body.userPrompt;
76
+
77
+ const msg = `【通知】/chart生成成功\nuserid:${userid}\nua:\n${uaJson}\nprompt:\n${prompt}\nres:${chartRes}`;
78
+ exports.feishuMsg(msg);
79
+ };
@@ -0,0 +1,56 @@
1
+ <!doctype html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
+ <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=yes" />
7
+ <link rel="dns-prefetch" href="//static-small.vincentqiao.com" />
8
+ <link rel="preconnect" href="//static-small.vincentqiao.com" crossorigin />
9
+ <meta name="renderer" content="webkit" />
10
+ <meta http-equiv="Cache-Control" content="no-siteapp" />
11
+ <meta name="keywords" content="AITuBiao.online | AI图表 | 免费在线工具 | 超25种图表一键生成" />
12
+ <meta name="description" content="AITuBiao.online | AI图表 | 免费在线工具 | 超25种图表一键生成" />
13
+ <meta name="author" content="AITuBiao.online" />
14
+ <meta name="robots" content="all" />
15
+ <link rel="icon" href="https://static-small.vincentqiao.com/aitubiao/favicon2.ico" />
16
+ <title>AITuBiao.online | AI图表 | 免费在线工具 | 超25种图表一键生成</title>
17
+ <style>
18
+ html,
19
+ body {
20
+ margin: 0;
21
+ padding: 0;
22
+ width: 100%;
23
+ height: 100%;
24
+ }
25
+
26
+ #root {
27
+ width: 100%;
28
+ height: 100%;
29
+ }
30
+ </style>
31
+ <script>
32
+ if (window.location.href.indexOf('aitubiao.online') > -1) {
33
+ (function (c, l, a, r, i, t, y) {
34
+ c[a] =
35
+ c[a] ||
36
+ function () {
37
+ (c[a].q = c[a].q || []).push(arguments);
38
+ };
39
+ t = l.createElement(r);
40
+ t.async = 1;
41
+ t.src = 'https://www.clarity.ms/tag/' + i;
42
+ y = l.getElementsByTagName(r)[0];
43
+ y.parentNode.insertBefore(t, y);
44
+ })(window, document, 'clarity', 'script', 't81gaw2amy');
45
+ }
46
+ </script>
47
+ <link href="https://static-small.vincentqiao.com/aitubiao/static/index.48a60059.css" rel="stylesheet" />
48
+ </head>
49
+ <body>
50
+ <div id="root"></div>
51
+ <script defer="defer" src="https://static-small.vincentqiao.com/pm.js"></script>
52
+ <script defer="defer" src="https://static-small.vincentqiao.com/aitubiao/static/react.90abd166.js"></script>
53
+ <script defer="defer" src="https://static-small.vincentqiao.com/aitubiao/static/axios.6128cc0a.js"></script>
54
+ <script defer="defer" src="https://static-small.vincentqiao.com/aitubiao/static/index.3637448b.js"></script>
55
+ </body>
56
+ </html>