abler-api 0.1.53 → 0.1.55
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/dist/cjs/pp-util.js +30 -4
- package/package.json +1 -1
package/dist/cjs/pp-util.js
CHANGED
|
@@ -217,7 +217,7 @@ class apiUtil$2 {
|
|
|
217
217
|
*/
|
|
218
218
|
|
|
219
219
|
|
|
220
|
-
static apiSuccess(data, req) {
|
|
220
|
+
static apiSuccess(data, req, spOrderNum) {
|
|
221
221
|
let response = {
|
|
222
222
|
success: true,
|
|
223
223
|
stateCode: 0,
|
|
@@ -225,6 +225,10 @@ class apiUtil$2 {
|
|
|
225
225
|
datetime: new Date()
|
|
226
226
|
};
|
|
227
227
|
|
|
228
|
+
if (spOrderNum) {
|
|
229
|
+
response.spOrderNum = spOrderNum;
|
|
230
|
+
}
|
|
231
|
+
|
|
228
232
|
if (req && req.headers) {
|
|
229
233
|
let userAgent = req.headers["user-agent"];
|
|
230
234
|
|
|
@@ -1212,7 +1216,7 @@ class apiUtil$2 {
|
|
|
1212
1216
|
static async $checkToken(req, res, next) {
|
|
1213
1217
|
try {
|
|
1214
1218
|
await apiUtil$2.checkRequestToken(req);
|
|
1215
|
-
|
|
1219
|
+
next();
|
|
1216
1220
|
} catch (e) {
|
|
1217
1221
|
res.send(err$2.ERROR(e));
|
|
1218
1222
|
}
|
|
@@ -1273,7 +1277,7 @@ class apiUtil$2 {
|
|
|
1273
1277
|
|
|
1274
1278
|
static $signatureVerified(req, res, next) {
|
|
1275
1279
|
req.signatureVerified = true;
|
|
1276
|
-
|
|
1280
|
+
next();
|
|
1277
1281
|
}
|
|
1278
1282
|
/**
|
|
1279
1283
|
* 标识此请求是从前端发过来的,比如移动端、PC浏览器等,区别于SPO一般的服务端后台请求。
|
|
@@ -1455,7 +1459,7 @@ class apiUtil$2 {
|
|
|
1455
1459
|
return res.status(e.status || 500).send(e.error || e);
|
|
1456
1460
|
}
|
|
1457
1461
|
|
|
1458
|
-
|
|
1462
|
+
next();
|
|
1459
1463
|
} //#endregion
|
|
1460
1464
|
//region ====一些通用服务功能
|
|
1461
1465
|
|
|
@@ -1524,6 +1528,28 @@ class apiUtil$2 {
|
|
|
1524
1528
|
text = lines.join('\r\n');
|
|
1525
1529
|
await fs$1.async_writeFile(fileName, text);
|
|
1526
1530
|
return n;
|
|
1531
|
+
}
|
|
1532
|
+
/**
|
|
1533
|
+
* 创建验证码对象
|
|
1534
|
+
* npm i svg-captcha
|
|
1535
|
+
* npm i svg2png
|
|
1536
|
+
*/
|
|
1537
|
+
|
|
1538
|
+
|
|
1539
|
+
static createSvgCaptcha(options) {
|
|
1540
|
+
const captcha = svgCaptcha.create({
|
|
1541
|
+
inverse: options.hasOwnProperty('inverse') ? options.inverse : false,
|
|
1542
|
+
fontSize: options.fontSize || 48,
|
|
1543
|
+
noise: options.noise || 2,
|
|
1544
|
+
width: options.width || 150,
|
|
1545
|
+
height: options.height || 75,
|
|
1546
|
+
size: options.size || 4,
|
|
1547
|
+
charPreset: options.charPreset || '0123456789',
|
|
1548
|
+
ignoreChars: options.ignoreChars || '0oli',
|
|
1549
|
+
color: options.hasOwnProperty('color') ? options.color : true,
|
|
1550
|
+
background: options.background || '#cc9966'
|
|
1551
|
+
});
|
|
1552
|
+
return captcha;
|
|
1527
1553
|
} //#endregion
|
|
1528
1554
|
|
|
1529
1555
|
|