abler-api 0.1.1 → 0.1.2
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 +25 -0
- package/dist/es/pp-util.js +25 -0
- package/package.json +1 -1
package/dist/cjs/pp-util.js
CHANGED
|
@@ -293,6 +293,31 @@ class apiUtil$1 {
|
|
|
293
293
|
*/
|
|
294
294
|
|
|
295
295
|
|
|
296
|
+
static sendResponse(response, promise) {
|
|
297
|
+
promise.then(function (data) {
|
|
298
|
+
if (!response.finished) {
|
|
299
|
+
try {
|
|
300
|
+
response.send(data);
|
|
301
|
+
} catch (e) {
|
|
302
|
+
console.log(`response.send 出错了,req.url: ${response.req.url}, response:`, response);
|
|
303
|
+
console.log("异常信息", e);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}, function (error) {
|
|
307
|
+
console.log('ERROR:', error);
|
|
308
|
+
|
|
309
|
+
if (!response.finished) {
|
|
310
|
+
response.send(error);
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* API 服务结束,包装数据并发送响应
|
|
316
|
+
* @param response
|
|
317
|
+
* @param promise
|
|
318
|
+
*/
|
|
319
|
+
|
|
320
|
+
|
|
296
321
|
static async responseOf(response, promise) {
|
|
297
322
|
promise.then(function (data) {
|
|
298
323
|
// console.log('RES:', apiSuccess(data));
|
package/dist/es/pp-util.js
CHANGED
|
@@ -285,6 +285,31 @@ class apiUtil$1 {
|
|
|
285
285
|
*/
|
|
286
286
|
|
|
287
287
|
|
|
288
|
+
static sendResponse(response, promise) {
|
|
289
|
+
promise.then(function (data) {
|
|
290
|
+
if (!response.finished) {
|
|
291
|
+
try {
|
|
292
|
+
response.send(data);
|
|
293
|
+
} catch (e) {
|
|
294
|
+
console.log(`response.send 出错了,req.url: ${response.req.url}, response:`, response);
|
|
295
|
+
console.log("异常信息", e);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}, function (error) {
|
|
299
|
+
console.log('ERROR:', error);
|
|
300
|
+
|
|
301
|
+
if (!response.finished) {
|
|
302
|
+
response.send(error);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* API 服务结束,包装数据并发送响应
|
|
308
|
+
* @param response
|
|
309
|
+
* @param promise
|
|
310
|
+
*/
|
|
311
|
+
|
|
312
|
+
|
|
288
313
|
static async responseOf(response, promise) {
|
|
289
314
|
promise.then(function (data) {
|
|
290
315
|
// console.log('RES:', apiSuccess(data));
|