ming_node 2.9.6 → 2.9.7
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +15 -8
- package/package.json +1 -1
- package/utils/yuque/yuque.js +25 -0
package/index.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
* By : Minglie
|
4
4
|
* QQ: 934031452
|
5
5
|
* Date :2021.12.01
|
6
|
-
* version :2.9.
|
6
|
+
* version :2.9.7
|
7
7
|
*/
|
8
8
|
var http = require('http');
|
9
9
|
var https = require('https');
|
@@ -1501,11 +1501,14 @@ M.server = function () {
|
|
1501
1501
|
}
|
1502
1502
|
return isRest;
|
1503
1503
|
}
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1504
|
+
try {
|
1505
|
+
req.ip = req.headers['x-forwarded-for'] ||
|
1506
|
+
req.connection.remoteAddress ||
|
1507
|
+
req.socket.remoteAddress ||
|
1508
|
+
req.connection.socket.remoteAddress;
|
1509
|
+
}catch (e){
|
1510
|
+
req.ip="";
|
1511
|
+
}
|
1509
1512
|
//请求cookies封装
|
1510
1513
|
req.cookies = querystring.parse(req.headers['cookie'], "; ");
|
1511
1514
|
//设置浏览器cookies
|
@@ -1773,7 +1776,11 @@ M.server = function () {
|
|
1773
1776
|
}
|
1774
1777
|
} catch (e) {
|
1775
1778
|
console.error(e);
|
1776
|
-
|
1779
|
+
try {
|
1780
|
+
M["_gloable_exception_handle"](e,req,res);
|
1781
|
+
}catch (e){
|
1782
|
+
console.error("e2",e);
|
1783
|
+
}
|
1777
1784
|
}
|
1778
1785
|
}
|
1779
1786
|
|
@@ -1945,7 +1952,7 @@ M.server = function () {
|
|
1945
1952
|
//全局异常钩子
|
1946
1953
|
app.set("gloable_exception_handle",(err,req,res)=>{
|
1947
1954
|
console.error(err.stack)
|
1948
|
-
if (res && !res.alreadySend) {
|
1955
|
+
if (res && res.send && !res.alreadySend) {
|
1949
1956
|
// res.writeHead(500, { "Content-Type": "text/j;charset='utf-8'" });
|
1950
1957
|
res.send(M.result(err.message,false,-1));
|
1951
1958
|
}
|
package/package.json
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
M=require("ming_node");
|
2
|
+
let url=require("url");
|
3
|
+
|
4
|
+
|
5
|
+
//M.yuqueToken="ZW9aH3CUDFWvC0ZU6nzoozBg03smn6Y5D36LqB8x";
|
6
|
+
|
7
|
+
|
8
|
+
M.getYuque= async function (yuqueUrl,type){
|
9
|
+
M.reqComHeaders={"X-Auth-Token": M.yuqueToken,"User-Agent":"PostmanRuntime/7.26.1"}
|
10
|
+
type=type||"html";
|
11
|
+
let r= url.parse(yuqueUrl)
|
12
|
+
let host="https://"+r.hostname;
|
13
|
+
let all_path=yuqueUrl.split(host)[1];
|
14
|
+
let all_path_arr=all_path.split("/");
|
15
|
+
let yuqueApi=`${host}/api/v2/repos/${all_path_arr[1]}/${all_path_arr[2]}/docs/${all_path_arr[3]}`;
|
16
|
+
let r1=await M.get(yuqueApi);
|
17
|
+
let artileContent=r1.data.body;
|
18
|
+
artileContent=artileContent.replace(/\s+/g,'')
|
19
|
+
artileContent=artileContent.replace("```"+type,"")
|
20
|
+
artileContent=artileContent.replace("```","")
|
21
|
+
return artileContent;
|
22
|
+
}
|
23
|
+
|
24
|
+
|
25
|
+
|