@xrystal/core 3.25.4 → 3.25.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/package.json
CHANGED
|
@@ -26,13 +26,19 @@ export class BaseController {
|
|
|
26
26
|
if (Object.keys(query).length === 0 && typeof urlStr === 'string' && urlStr.includes('?')) {
|
|
27
27
|
query = qs.parse(urlStr.split('?')[1]);
|
|
28
28
|
}
|
|
29
|
+
const params = {
|
|
30
|
+
...(req.params || {}),
|
|
31
|
+
...(ctx.params || {}),
|
|
32
|
+
...(ctx.request?.params || {}),
|
|
33
|
+
...(ctx.request?.routeParams || {})
|
|
34
|
+
};
|
|
29
35
|
return {
|
|
30
36
|
url: urlStr,
|
|
31
37
|
method: ctx.method || req.method || ctx.request?.method || '',
|
|
32
38
|
headers: ctx.headers || req.headers || ctx.request?.headers || {},
|
|
33
39
|
body,
|
|
34
40
|
query,
|
|
35
|
-
params
|
|
41
|
+
params,
|
|
36
42
|
lang: ctx.lang || req.lang || 'en',
|
|
37
43
|
t: ctx.t || req.t || identityT,
|
|
38
44
|
accounts: ctx.accounts || req.accounts || ctx.user
|
|
@@ -90,8 +96,6 @@ export default class Controller extends BaseController {
|
|
|
90
96
|
payloadString = parts.slice(1).join(' ');
|
|
91
97
|
}
|
|
92
98
|
const params = payloadString.split('-').map(p => p.trim()).filter(p => p !== '');
|
|
93
|
-
// Kritik Düzeltme: Çiftlemeyi önlemek için parametreleri helper'a t() ile sarmadan gönderiyoruz
|
|
94
|
-
// Çünkü helper zaten kendi içinde t() kullanıyor
|
|
95
99
|
const p1 = params[0] || '';
|
|
96
100
|
const p2 = params.slice(1).join(' ');
|
|
97
101
|
if (responseMessageHelper[method]) {
|
|
@@ -104,7 +108,37 @@ export default class Controller extends BaseController {
|
|
|
104
108
|
const currentRes = this.res;
|
|
105
109
|
const store = this.currentStore;
|
|
106
110
|
try {
|
|
107
|
-
|
|
111
|
+
let parsedBody = currentReq.body;
|
|
112
|
+
const rawReq = store?.req || store?.ctx?.request || store?.ctx?.req;
|
|
113
|
+
if (this.protocol === ProtocolEnum.WEBSOCKET && typeof parsedBody === 'string') {
|
|
114
|
+
try {
|
|
115
|
+
parsedBody = JSON.parse(parsedBody);
|
|
116
|
+
}
|
|
117
|
+
catch (e) { }
|
|
118
|
+
}
|
|
119
|
+
else if (rawReq && (parsedBody instanceof ReadableStream || (parsedBody && typeof parsedBody.getReader === 'function'))) {
|
|
120
|
+
try {
|
|
121
|
+
const cloned = rawReq.clone ? rawReq.clone() : rawReq;
|
|
122
|
+
parsedBody = await cloned.json();
|
|
123
|
+
}
|
|
124
|
+
catch (e) {
|
|
125
|
+
try {
|
|
126
|
+
parsedBody = await rawReq.text();
|
|
127
|
+
try {
|
|
128
|
+
parsedBody = JSON.parse(parsedBody);
|
|
129
|
+
}
|
|
130
|
+
catch (e) { }
|
|
131
|
+
}
|
|
132
|
+
catch (e2) {
|
|
133
|
+
parsedBody = {};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else if (parsedBody && typeof parsedBody === 'object' && parsedBody.constructor?.name === 'FormData') {
|
|
138
|
+
parsedBody = Object.fromEntries(parsedBody.entries());
|
|
139
|
+
}
|
|
140
|
+
currentReq.body = parsedBody;
|
|
141
|
+
const p = { req: currentReq, res: currentRes, body: parsedBody, query: currentReq.query, params: currentReq.params, t: currentReq.t, accounts: currentReq.accounts };
|
|
108
142
|
const extractMeta = (obj) => {
|
|
109
143
|
if (!obj || typeof obj !== 'object')
|
|
110
144
|
return;
|