@shun-js/aibaiban-server 0.3.3

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://aibaiban.com/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://aibaiban.com/</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,45 @@
1
+ {
2
+ "name": "@shun-js/aibaiban-server",
3
+ "version": "0.3.3",
4
+ "description": "aibaiban.com server",
5
+ "keywords": [
6
+ "ai aibaiban"
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
+ "scripts": {
25
+ "pack": "cp ./static/index.html ./views/index.html",
26
+ "upload": "qcos fo ../../configs/aitubiao-web.json ./static aibaiban/static"
27
+ },
28
+ "dependencies": {
29
+ "@shun-js/shun-config": "^0.3.1",
30
+ "@shun-js/shun-service": "^0.3.1",
31
+ "qiao-file": "^5.0.6",
32
+ "qiao-log": "^5.1.9",
33
+ "qiao-rate-limit": "^5.8.8",
34
+ "qiao-redis": "^5.8.9",
35
+ "qiao-z": "^5.8.9",
36
+ "qiao-z-nuser": "^5.8.8",
37
+ "qiao-z-service": "^5.8.8",
38
+ "qiao-z-sms": "^5.8.8"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public",
42
+ "registry": "https://registry.npmjs.org/"
43
+ },
44
+ "gitHead": "c2d34db4559d60de157035ddb5899081847f09e9"
45
+ }
@@ -0,0 +1,12 @@
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
+ };
@@ -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,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,16 @@
1
+ /**
2
+ * index
3
+ * @param {*} req
4
+ * @param {*} res
5
+ */
6
+ exports.index = async (req, res) => {
7
+ // const
8
+ const pagePath = './views/index.html';
9
+
10
+ // is static
11
+ const isStatic = await res.staticRender(pagePath);
12
+ if (isStatic) return;
13
+
14
+ // render
15
+ res.render(pagePath, {}, true);
16
+ };
@@ -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,77 @@
1
+ // services
2
+ const { feishuBot } = require('@shun-js/shun-service');
3
+
4
+ /**
5
+ * feishuMsg
6
+ * @param {*} msg
7
+ */
8
+ exports.feishuMsg = (msg) => {
9
+ if (global.QZ_CONFIG.env !== 'production') return;
10
+
11
+ feishuBot({
12
+ url: global.QZ_CONFIG.feishu.url,
13
+ feishuUrl: global.QZ_CONFIG.feishu.feishuUrl,
14
+ feishuMsg: msg,
15
+ });
16
+ };
17
+
18
+ // is bot
19
+ function isBot(req) {
20
+ const ua = req.useragent;
21
+ const hasOSName = ua && ua.os && ua.os.name;
22
+ const isGoogleBot = ua && ua.browser && ua.browser.name === 'Googlebot';
23
+ const isMetaBot = ua && ua.browser && ua.browser.name === 'meta-externalagent';
24
+ const isSafariBot = ua && ua.engine && ua.engine.name === 'WebKit' && ua.engine.version === '605.1.15';
25
+ return !hasOSName || isGoogleBot || isMetaBot || isSafariBot;
26
+ }
27
+
28
+ /**
29
+ * errorFeishuMsg
30
+ * @param {*} req
31
+ * @param {*} msg
32
+ * @returns
33
+ */
34
+ exports.errorFeishuMsg = (req, msg) => {
35
+ // check
36
+ if (isBot(req)) return;
37
+
38
+ // msg
39
+ const uaJson = JSON.stringify(req.useragent || {});
40
+ exports.feishuMsg(`【通知】服务异常,${msg},请查看日志,ua:${uaJson}`);
41
+ };
42
+
43
+ /**
44
+ * chartFeishuMsg
45
+ * @param {*} req
46
+ * @returns
47
+ */
48
+ exports.chartFeishuMsg = (req) => {
49
+ // check
50
+ if (isBot(req)) return;
51
+
52
+ // msg
53
+ const uaJson = JSON.stringify(req.useragent || {});
54
+ const userid = req.headers.userid;
55
+ const prompt = req.body.userPrompt;
56
+
57
+ const msg = `【通知】/chart被访问\nuserid:${userid}\nua:\n${uaJson}\nprompt:\n${prompt}`;
58
+ exports.feishuMsg(msg);
59
+ };
60
+
61
+ /**
62
+ * chartResFeishuMsg
63
+ * @param {*} req
64
+ * @returns
65
+ */
66
+ exports.chartResFeishuMsg = (req, chartRes) => {
67
+ // check
68
+ if (isBot(req)) return;
69
+
70
+ // msg
71
+ const uaJson = JSON.stringify(req.useragent || {});
72
+ const userid = req.headers.userid;
73
+ const prompt = req.body.userPrompt;
74
+
75
+ const msg = `【通知】/chart生成成功\nuserid:${userid}\nua:\n${uaJson}\nprompt:\n${prompt}\nres:${chartRes}`;
76
+ exports.feishuMsg(msg);
77
+ };
@@ -0,0 +1,18 @@
1
+ <!doctype html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>AI白板 - 智能协作白板工具</title>
8
+ <script
9
+ type="module"
10
+ crossorigin
11
+ src="https://static-small.vincentqiao.com/aibaiban/static/index-D0Up6fVw.js"
12
+ ></script>
13
+ <link rel="stylesheet" crossorigin href="https://static-small.vincentqiao.com/aibaiban/static/index-DbDPw9K7.css" />
14
+ </head>
15
+ <body>
16
+ <div id="root"></div>
17
+ </body>
18
+ </html>