@jayfong/x-server 2.49.4 → 2.49.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/lib/_cjs/cli/cli.js +0 -0
- package/lib/_cjs/core/server.js +5 -1
- package/lib/core/server.js +4 -0
- package/package.json +1 -1
package/lib/_cjs/cli/cli.js
CHANGED
|
File without changes
|
package/lib/_cjs/core/server.js
CHANGED
|
@@ -4,6 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.Server = void 0;
|
|
6
6
|
var _interopRequireWildcard2 = _interopRequireDefault(require("@babel/runtime/helpers/interopRequireWildcard"));
|
|
7
|
+
var _nodeProcess = _interopRequireDefault(require("node:process"));
|
|
7
8
|
var _fastify = _interopRequireDefault(require("fastify"));
|
|
8
9
|
var _vtils = require("vtils");
|
|
9
10
|
var _x = require("../x");
|
|
@@ -15,6 +16,9 @@ class Server {
|
|
|
15
16
|
this.fastify = void 0;
|
|
16
17
|
this.routes = [];
|
|
17
18
|
Server.options = options;
|
|
19
|
+
_nodeProcess.default.on('unhandledRejection', (reason, promise) => {
|
|
20
|
+
console.error('未捕获的错误', reason, promise);
|
|
21
|
+
});
|
|
18
22
|
}
|
|
19
23
|
async start() {
|
|
20
24
|
this.applyServices();
|
|
@@ -33,7 +37,7 @@ class Server {
|
|
|
33
37
|
}
|
|
34
38
|
async prepareFastify() {
|
|
35
39
|
this.fastify = await (0, _fastify.default)({
|
|
36
|
-
logger:
|
|
40
|
+
logger: _nodeProcess.default.env.NODE_ENV === 'development' ? {
|
|
37
41
|
transport: {
|
|
38
42
|
target: 'pino-pretty'
|
|
39
43
|
}
|
package/lib/core/server.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
1
2
|
import Fastify from 'fastify';
|
|
2
3
|
import { base64UrlDecode, castArray, keyBy, noop, rot13 } from 'vtils';
|
|
3
4
|
import { x } from "../x";
|
|
@@ -9,6 +10,9 @@ export class Server {
|
|
|
9
10
|
this.fastify = void 0;
|
|
10
11
|
this.routes = [];
|
|
11
12
|
Server.options = options;
|
|
13
|
+
process.on('unhandledRejection', (reason, promise) => {
|
|
14
|
+
console.error('未捕获的错误', reason, promise);
|
|
15
|
+
});
|
|
12
16
|
}
|
|
13
17
|
async start() {
|
|
14
18
|
this.applyServices();
|