@domain.js/main 1.1.0 → 1.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/http/index.js +4 -1
- package/dist/http/utils.js +1 -2
- package/package.json +1 -1
package/dist/http/index.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Main = Main;
|
|
7
7
|
const formbody_1 = __importDefault(require("@fastify/formbody"));
|
|
8
8
|
const multipart_1 = __importDefault(require("@fastify/multipart"));
|
|
9
|
+
const crypto_1 = require("crypto");
|
|
9
10
|
const fastify_1 = __importDefault(require("fastify"));
|
|
10
11
|
const fastify_socket_io_1 = __importDefault(require("fastify-socket.io"));
|
|
11
12
|
const router_1 = require("./router");
|
|
@@ -14,7 +15,9 @@ const utils_1 = require("./utils");
|
|
|
14
15
|
function Main(cnf, deps) {
|
|
15
16
|
const utils = (0, utils_1.Utils)(cnf);
|
|
16
17
|
const { routers, domain, httpCodes, makeProfileHook, socketLogger } = deps;
|
|
17
|
-
const server = (0, fastify_1.default)(
|
|
18
|
+
const server = (0, fastify_1.default)({
|
|
19
|
+
genReqId: () => (0, crypto_1.randomUUID)(),
|
|
20
|
+
});
|
|
18
21
|
server.setErrorHandler((error, request, reply) => {
|
|
19
22
|
const { code, message, data } = error;
|
|
20
23
|
const statusCode = httpCodes[code] || 500;
|
package/dist/http/utils.js
CHANGED
|
@@ -142,7 +142,6 @@ function Utils(cnf) {
|
|
|
142
142
|
* 构造领域方法所需的 params 参数
|
|
143
143
|
*/
|
|
144
144
|
async makeParams(req) {
|
|
145
|
-
var _a;
|
|
146
145
|
let params = { ...(req.query || {}), ...(req.params || {}) };
|
|
147
146
|
if (lodash_1.default.isObject(req.body) && !Array.isArray(req.body)) {
|
|
148
147
|
params = { ...(req.body || {}), ...params };
|
|
@@ -153,7 +152,7 @@ function Utils(cnf) {
|
|
|
153
152
|
// 处理 multipart:同时解析字段与文件
|
|
154
153
|
let files = {};
|
|
155
154
|
try {
|
|
156
|
-
if (
|
|
155
|
+
if (req.isMultipart()) {
|
|
157
156
|
const fields = {};
|
|
158
157
|
const parts = req.parts();
|
|
159
158
|
for await (const part of parts) {
|