@xrystal/core 3.26.0 → 3.26.1
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
|
@@ -30,6 +30,8 @@ export declare const controllerContextStorage: AsyncLocalStorage<{
|
|
|
30
30
|
_statusCode?: number;
|
|
31
31
|
_contentType?: string;
|
|
32
32
|
_isRaw?: boolean;
|
|
33
|
+
_parsedBody?: any;
|
|
34
|
+
_parsedQuery?: any;
|
|
33
35
|
};
|
|
34
36
|
}>;
|
|
35
37
|
export declare const getControllerCtx: () => {
|
|
@@ -43,6 +45,8 @@ export declare const getControllerCtx: () => {
|
|
|
43
45
|
_statusCode?: number;
|
|
44
46
|
_contentType?: string;
|
|
45
47
|
_isRaw?: boolean;
|
|
48
|
+
_parsedBody?: any;
|
|
49
|
+
_parsedQuery?: any;
|
|
46
50
|
};
|
|
47
51
|
};
|
|
48
52
|
export declare abstract class BaseController {
|
|
@@ -61,6 +65,8 @@ export declare abstract class BaseController {
|
|
|
61
65
|
_statusCode?: number;
|
|
62
66
|
_contentType?: string;
|
|
63
67
|
_isRaw?: boolean;
|
|
68
|
+
_parsedBody?: any;
|
|
69
|
+
_parsedQuery?: any;
|
|
64
70
|
};
|
|
65
71
|
};
|
|
66
72
|
protected get req(): CustomRequest;
|
|
@@ -20,8 +20,9 @@ export class BaseController {
|
|
|
20
20
|
const ctx = store?.ctx || {};
|
|
21
21
|
const req = store?.req || {};
|
|
22
22
|
const identityT = (k) => k;
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
// Önce store içindeki parse edilmiş veriye bak, yoksa orijinaline git
|
|
24
|
+
const body = store?.metadata?._parsedBody || ctx.body || req.body || ctx.request?.body || {};
|
|
25
|
+
let query = store?.metadata?._parsedQuery || ctx.query || req.query || ctx.request?.query || {};
|
|
25
26
|
const urlStr = ctx.url || req.url || ctx.request?.url || '';
|
|
26
27
|
if ((!query || Object.keys(query).length === 0) && typeof urlStr === 'string' && urlStr.includes('?')) {
|
|
27
28
|
const parts = urlStr.split('?');
|
|
@@ -190,19 +191,12 @@ export default class Controller extends BaseController {
|
|
|
190
191
|
}
|
|
191
192
|
const finalBody = parsedBody || {};
|
|
192
193
|
const finalQuery = parsedQuery || {};
|
|
194
|
+
// readonly hatasını önlemek için asıl objeyi değil metadata'yı güncelliyoruz
|
|
193
195
|
if (store) {
|
|
194
|
-
if (store.
|
|
195
|
-
store.
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
if (store.req) {
|
|
199
|
-
store.req.body = finalBody;
|
|
200
|
-
store.req.query = finalQuery;
|
|
201
|
-
}
|
|
202
|
-
if (store.ctx?.request) {
|
|
203
|
-
store.ctx.request.body = finalBody;
|
|
204
|
-
store.ctx.request.query = finalQuery;
|
|
205
|
-
}
|
|
196
|
+
if (!store.metadata)
|
|
197
|
+
store.metadata = { locals: {} };
|
|
198
|
+
store.metadata._parsedBody = finalBody;
|
|
199
|
+
store.metadata._parsedQuery = finalQuery;
|
|
206
200
|
}
|
|
207
201
|
const currentReq = this.req;
|
|
208
202
|
const p = { req: currentReq, res: currentRes, body: currentReq.body, query: currentReq.query, params: currentReq.params, t: currentReq.t, accounts: currentReq.accounts };
|